This is what google explains about RECEIVER_EXPORTED, RECEIVER_NOT_EXPORTED:
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.
When I want to use broadcasts sent from the system Google says I need to use RECEIVER_EXPORTED but when I tested with "android.intent.action.AIRPLANE_MODE"
and "RECEIVER_NOT_EXPORTED"
.
I received a broadcast event.
Can anyone explain that sentence?
There might be an error in their document or they changed their mind, because according to ContextCompat documentation, you can use:
RECEIVER_NOT_EXPORTED if you only want your receiver to be able to receive broadcasts from the system or your own app.
In my opinion, it's safer like this, because we don't want our receiver to be open to all applications just to get system broadcasts.
(edited) I found also this on the RECEIVER_NOT_EXPORTED documentation:
Has the same behavior as marking a statically registered receiver with "exported=false"
And when I look at receiver documentation, for the exported attribute, I read:
If "false", the only messages the broadcast receiver can receive are those sent by the system, components of the same application, or applications with the same user ID
So I'm confident enough that the implementation is coherent and there is a small error in the documentation