1

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.

2
  • 1
    This is too abstract to comprehend, please add the receiver you are talking about. Commented Jul 30, 2024 at 3:18
  • Martin's right. Please provide a minimal example in your questions, if only to be sure that we're all on the same page. That said, I happened to have come across this the other day, and it's simply a behavior change starting in version 14: "Implicit intents are only delivered to exported components. Apps must either use an explicit intent to deliver to unexported components, or mark the component as exported." Commented Jul 30, 2024 at 6:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.