RECEIVER_NOT_EXPORTED or RECEIVER_EXPORTED has to be set when registering receivers in Android 34. Not doing so will crash the application.
It's my understanding that RECEIVER_NOT_EXPORTED is the better option.
From the docs:
Runtime-registered broadcasts receivers must specify export behavior
Apps and services that target Android 14 (API level 34) or higher and use context-registered receivers are required to specify a flag to indicate whether or not the receiver should be exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED, respectively. This requirement helps protect apps from security vulnerabilities by leveraging the features for these receivers introduced in Android 13.
Exception for receivers that receive only system broadcasts
If your app is registering a receiver only for system broadcasts through Context#registerReceiver methods, such as Context#registerReceiver(), then it shouldn't specify a flag when registering the receiver.
From implementation docs:
Choose whether the broadcast receiver should be exported and visible to other apps on the device. If this receiver is listening for broadcasts sent from the system or from other apps—even other apps that you own—use the RECEIVER_EXPORTED flag. If instead this receiver is listening only for broadcasts sent by your app, use the RECEIVER_NOT_EXPORTED flag.
Old versions of Android should run the same as before.
RECEIVER_NOT_EXPORTED or RECEIVER_EXPORTED has to be set when registering receivers in Android 34. Not doing so will crash the application.
It's my understanding that RECEIVER_NOT_EXPORTED is the better option.
From the docs:
From implementation docs:
Old versions of Android should run the same as before.