Open karaushu opened 1 year ago
have you found the solution here?
in the file react-native-thermal-receipt-printer/android/src/main/java/com/pinmi/react/printer/adapter/USBPrinterAdapter.java
replace this.mPermissionIndent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), 0); by this.mPermissionIndent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_IMMUTABLE);
in the file react-native-thermal-receipt-printer/android/src/main/java/com/pinmi/react/printer/adapter/USBPrinterAdapter.java
replace this.mPermissionIndent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), 0); by this.mPermissionIndent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_IMMUTABLE);
thanks for the response. The error is gone after I did this. however, the app crashes after the usb permission is accepted. any idea why?
nvm. I used FLAG_MUTABLE instead of FLAG_IMMUTABLE and it worked.
Current Behavior
When running
USBPrinter.init()
got next error:Targeting S+ (version 10000 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
minSdkVersion
- 21compileSdkVersion
- 31targetSdkVersion
- 31buildToolsVersion
- 31Have been trying to update deps in gradle (androidx.work:work-runtime-ktx: v2.6.0, 2.7.0, 2.7.1)
Your Environment