背景: 我注意到对于其中的常规 Activity ,任何应用程序都可以打开我的应用程序的 Activity 。
问题: 是否可以只允许我自己的应用程序(或应用程序或包)在同一范围内发送和接收 Intent ,以便其他应用程序无法接收它们或干扰应用程序的流程?
例子: 假设我有一个监听某种 Intent 的 broadcastReceiver,但这个 Intent 仅供驻留在我的应用程序内部或我创建的另一个应用程序内部的另一个服务/Activity 使用,但我不想其他人能够使用此 Intent 。
请帮助我。
最佳答案
Set an explicit application package name that limits the components this Intent will resolve to. If left to the default value of null, all components in all applications will considered. If non-null, the Intent can only match the components in the given application package.
或者您可以使用 setSelector()
,但不能同时使用。
关于android - 是否可以使用私有(private) Intent 而不是全局 Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9737908/