mirror of
https://github.com/mik3y/usb-serial-for-android.git
synced 2026-08-11 16:32:53 +00:00
target sdk 34
Pending intent and broadcast receiver changed according to sdk 34 release notes. Permisssion dialog now shown while fragment is paused.
This commit is contained in:
+4
-2
@@ -86,9 +86,11 @@ public class UsbWrapper implements SerialInputOutputManager.Listener {
|
||||
}
|
||||
};
|
||||
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0;
|
||||
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent("com.android.example.USB_PERMISSION"), flags);
|
||||
Intent intent = new Intent("com.android.example.USB_PERMISSION");
|
||||
intent.setPackage(context.getPackageName());
|
||||
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, intent, flags);
|
||||
IntentFilter filter = new IntentFilter("com.android.example.USB_PERMISSION");
|
||||
context.registerReceiver(usbReceiver, filter);
|
||||
context.registerReceiver(usbReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
|
||||
usbManager.requestPermission(serialDriver.getDevice(), permissionIntent);
|
||||
for(int i=0; i<5000; i++) {
|
||||
if(granted[0] != null) break;
|
||||
|
||||
Reference in New Issue
Block a user