Surile / react-native-sunmi-printer

商米内置打印机
MIT License
44 stars 28 forks source link

Fix security exception on Android 14. #47

Closed alexsegura closed 3 months ago

alexsegura commented 4 months ago

When running on Android 14, the app crashes immediately with the following error:

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

Capture d’écran 2024-03-18 à 18 03 31

This is a hotfix, seems a better solution would be to use ContextCompat

alexsegura commented 3 months ago

Actually this is not the good implementation, it crashes on devices with Android <= 10 (from what I see).

Fatal Exception: java.lang.NoSuchMethodError: No virtual method registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;I)Landroid/content/Intent; in class Landroid/content/ContextWrapper; or its super classes (declaration of 'android.content.ContextWrapper' appears in /system/framework/framework.jar)

I will send another PR using ContextCompat