1
0
mirror of https://github.com/mik3y/usb-serial-for-android.git synced 2026-08-11 08:22:52 +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:
Kai Morich
2024-02-18 13:09:23 +01:00
parent 83646d6955
commit 26a2f9363e
4 changed files with 25 additions and 11 deletions
+2 -2
View File
@@ -4,11 +4,11 @@ plugins {
}
android {
compileSdkVersion 33
compileSdkVersion 34
defaultConfig {
minSdkVersion 17
targetSdkVersion 33
targetSdkVersion 34
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -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;