Open darkSuperman opened 4 months ago
I also have this issue please solve this ASAP.
Use PendingIntent.FLAG_IMMUTABLE
instead of custom PENDING_FLAG_IMMUTABLE
And also change this: https://github.com/jiangdongguo/AndroidUSBCamera/blob/ebfd9437eb6e23e30f583a0151474b2fa6267fca/libuvc/src/main/java/com/jiangdg/usb/USBMonitor.java#L189
to:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(mUsbReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
context.registerReceiver(mUsbReceiver, filter);
}
Hope this help.
@lolosssss even this is not helping. Any other solutions?
@darkSuperman are you able to find any solutions?
@lolosssss even this is not helping. Any other solutions? Have you solved it yet?
@lolosssss Any updates on this ?
Intent intent = new Intent(ACTION_USB_PERMISSION);
intent.setPackage(context.getPackageName()); // add it
mPermissionIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_MUTABLE);
final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(mUsbReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
context.registerReceiver(mUsbReceiver, filter);
}
work for Galaxy S23 , Android 14
xiaohua717
Intent intent = new Intent(ACTION_USB_PERMISSION); intent.setPackage(context.getPackageName()); // add it mPermissionIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_MUTABLE); final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { context.registerReceiver(mUsbReceiver, filter, Context.RECEIVER_NOT_EXPORTED); } else { context.registerReceiver(mUsbReceiver, filter); }
work for Galaxy S23 , Android 14
Intent intent = new Intent(ACTION_USB_PERMISSION); intent.setPackage(context.getPackageName()); // add it mPermissionIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_MUTABLE); final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { context.registerReceiver(mUsbReceiver, filter, Context.RECEIVER_NOT_EXPORTED); } else { context.registerReceiver(mUsbReceiver, filter); }
work for Galaxy S23 , Android 14
Hi I edited the file but I'm unable to compile. Im a Newbie to java and other stuff. So can you please help me. Thanks
Use
PendingIntent.FLAG_IMMUTABLE
instead of customPENDING_FLAG_IMMUTABLE
And also change this:
to:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { context.registerReceiver(mUsbReceiver, filter, Context.RECEIVER_NOT_EXPORTED); } else { context.registerReceiver(mUsbReceiver, filter); }
Hope this help.
@jiangdongguo please check on this. \
java.lang.IllegalArgumentException:com.nextai.object: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
查了一下: https://stackoverflow.com/questions/77275691/targeting-u-version-34-and-above-disallows-creating-or-retrieving-a-pendingin
错误表明,从 Android 14(API 34)开始,如果您在具有 FLAG_MUTABLE 的 PendingIntent 对象内有一个隐式意图,您的应用就会崩溃。
如果您不需要FLAG_MUTABLE标志,则只需将其更改为FLAG_IMMUTABLE。但是,如果您的应用需要可变意图,那么我建议采用以下解决方案之一: val implicitIntent = Intent("com.example.app.action.WHATEVER") val implicitPendingIntent = if (Build.VERSION.SDK_INT >= 34) { PendingIntent.getBroadcast(this, 0, implicitIntent, PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT) } else { PendingIntent.getBroadcast(this, 0, implicitIntent, PendingIntent.FLAG_MUTABLE) }
可以更新一下嘛?