Android broadcast to specific 3rd party applications

孤街浪徒 提交于 2019-12-23 13:02:09

问题


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,


回答1:


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);


来源:https://stackoverflow.com/questions/26023829/android-broadcast-to-specific-3rd-party-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!