felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.81k stars 589 forks source link

Issue with SDK > 31 on Android 12 #360

Open bdureau opened 1 year ago

bdureau commented 1 year ago

Looks like it does not request the permission correctly on Android 12. You might be able to fix it like this This is on line 155 on file SerialPortBuilder.java //PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0); PendingIntent mPendingIntent = null; if(android.os.Build.VERSION.SDK_INT >= 31) { mPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_IMMUTABLE); } else { mPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0); }

Unfortunately I am having trouble to build the library so I cannot really test it. I am quite happy to confirm if it works if someone explain how to build the lib Regards Boris

bdureau commented 1 year ago

I have managed to recompile the library and it works however I have had to add the following dependency for lib serial to work implementation 'com.squareup.okio:okio:3.3.0'