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:
@@ -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"
|
||||
|
||||
+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