在Android中如何可以指定哪些活动应该处理我的意图 [英] In Android How can I specify which activity should handle my intent
本文介绍了在Android中如何可以指定哪些活动应该处理我的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个应用程序 A和B。
我要开始从 A
在 B
的活动。所以我使用的隐意图。有没有什么办法,以确保只有在活动 B
被调用的意图?
I want to start an activity in B
from A
. So I am using an implicit intent. Is there any way to make sure that only the activity in B
is invoked by the intent?
即在一个黑客把他的应用程序的设备试图接收相同意图的情况下,我想prevent这一点。
i.e In the event that a hacker puts his application on the device trying to receive the same intent, I want to prevent that.
推荐答案
使用的setPackage方法来指定whicj应用程序应该处理这个意图。下面是一个例子使用ZXing:
Use the setPackage method to specify whicj app should handle the intent. Here is an example using ZXing:
final String ZXING = "com.google.zxing.client.android";
Intent intent = new Intent(ZXING + ".SCAN");
intent.setPackage(ZXING);
这篇关于在Android中如何可以指定哪些活动应该处理我的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文