my application defines events that other apps installed on the device could be registered to (like other apps can register to google play services location updates and activity recognition events).
google play services process notify this types of events via PendingIntent
provided by the receiving app.
I prefer to do it by sending a broadcast restricted by permissions, and I think that from a good reason: PendingIntent
cannot be saved in persistent way, so every time my app will shout down, the apps that that registered to my events will have to re-register to my events..
the problem: in the link I provided, you can see how to restrict broadcast by custom permission declared in both sides (the broadcast sender application, and the receiving application), but what if I need to decide from the senders side dynamically from a list I'm getting from the server, what are the apps that allowed to receive the broadcast?
I don't find any reference or example in the web how to do so.
I guess it suppose to be possible somehow, because seems like google play services is using this approach for notifying GCM push notifications only to the relevant receiver...
please help me understand how can I do such a thing.
but what if I need to decide from the senders side dynamically from a list I'm getting from the server, what are the apps that allowed to receive the broadcast? I don't find any reference or example in the web how to do so.
Use an explicit Intent
, where you have set the ComponentName
of the specific BroadcastReceiver
that you are "broadcasting" to. You will need to "broadcast" such an explicit Intent
once per app that is "allowed to receive the broadcast".