I want to send and receive Broadcast between Service and Activity.
I registered programmatically created BroadcastReceiver both in Service and Activity with using flag RECEIVER_NOT_EXPORTED for make sure Broadcast is only work in own app.
But then a Broadcast was never received in both sides.
So I changed this flag from RECEIVER_NOT_EXPORTED to RECEIVER_EXPORTED and now it works.
RECEIVER_NOT_EXPORTED in the docs,
If you flag your receiver with RECEIVER_NOT_EXPORTED, the receiver is able to receive some system broadcasts and broadcasts from your app, but not broadcasts from the highly privileged apps.
The Service and Activity that I am using are in the same app and have registered the correct IntentFilters.
In my expectation, it should work no matter what flag is used.
Why is this happening?
I'm using the receiver for a custom action, not the system broadcast.
receiveryou are talking about.