Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Intent(ACTION_USB_PERMISSION), 0); doesn't work in recent Android version #370

Open
blotfi opened this issue Feb 27, 2024 · 1 comment

Comments

@blotfi
Copy link

blotfi commented Feb 27, 2024

in UsbService.java

replace with

private void requestUserPermission() {
        Log.d(TAG, String.format("requestUserPermission(%X:%X)", device.getVendorId(), device.getProductId() ) );
        PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0,
                new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE);
        usbManager.requestPermission(device, mPendingIntent);
    }
@SerSerch
Copy link

SerSerch commented May 1, 2024

int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? PendingIntent.FLAG_IMMUTABLE : 0;
PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, 0 , new Intent(Definitions.ACTION_USB_PERMISSION), flags);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants