Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android broadcast to specific 3rd party applications

I developed an android app and it sends broadcast with a custom permission.

public abstract void sendBroadcast (Intent intent, String receiverPermission)

Now any 3rd party app that has a broadcast receiver and declared the custom permission in their manifest will be able to listen to the broadcast.

Is there a way to control which application can receive the broadcast from my application?

what I'm afraid of is the custom permission gets in the hand of the wrong people and they start creating their own app to listen to my broadcasts.

FYI, the protection-level is set to dangerous.

Thanks,

like image 738
pdiddy Avatar asked Sep 24 '14 18:09

pdiddy


1 Answers

You can set the receiving package name of the 3rd party app in your intent as follow:

intent.setPackage({3rd pary app package name});
context.sendBroadcast(intent);
like image 108
moh.sukhni Avatar answered Sep 27 '22 16:09

moh.sukhni