The message "one of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts" refers to a new requirement introduced in Android 13 and enforced in Android 14 and above. This means that when an app registers a broadcast receiver programmatically (not only in the manifest), it must specify explicitly whether the receiver is exported (able to receive broadcasts from other apps) or not exported (only receives broadcasts internal to the app). This is done by using the flags RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED in the call to registerReceiver.
- Use RECEIVER_EXPORTED if the broadcast receiver is intended to receive broadcasts from other apps or system broadcasts.
- Use RECEIVER_NOT_EXPORTED if the receiver should only receive broadcasts from within the same app (not from other apps or the system).
If these flags are not specified starting from Android 13/14, the system will throw a security exception. Example usage in code for Android 14+:
java
context.registerReceiver(broadcastReceiver, intentFilter, Context.RECEIVER_EXPORTED);
or
java
context.registerReceiver(broadcastReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED);
If the receiver is registered only for system broadcasts, this requirement does not apply. This update is part of Android's increased focus on security and explicit permissions for broadcast receivers to prevent unauthorized broadcast interceptions.