paystory-de / thermal-printer-cordova-plugin

Cordova wrapper for ESC/POS Thermal Printer library
Apache License 2.0
50 stars 39 forks source link

PendingIntent to FLAG_IMMUTABLE for Android 14 Compatibility #59

Open taylorlacort opened 4 months ago

taylorlacort commented 4 months ago

After updating compileSdkVersion and targetSdkVersion to 34 (Android 14), the application crashes when printing via USB using the ESCPOS-ThermalPrinter-Android library. The issue is related to the use of PendingIntent, which must be explicitly marked with FLAG_IMMUTABLE or FLAG_MUTABLE due to new security requirements in Android 14.

ERROR: java.lang.IllegalArgumentException: 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.