针对特定软件包的PACKAGE_ADDED的意图过滤器 [英] Intent filter for PACKAGE_ADDED for a specific package
本文介绍了针对特定软件包的PACKAGE_ADDED的意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android应用中,我正在收听PACKAGE_ADDED广播:
In my Android app, I'm catching the PACKAGE_ADDED broadcast:
<receiver android:name=".OnAppInstall">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
我的应用仅与特定配套应用的安装有关.意图中的数据字符串为:package:com.acme.myapp
.意图数据Uri是OpaqueUri
的实例; getHost()
,getPath()
和getQuery()
都返回null.
My app is only concerned with installation of a specific companion app. The data string in the intent goes: package:com.acme.myapp
. The intent data Uri is an instance of OpaqueUri
; getHost()
, getPath()
, and getQuery()
all return nulls.
我可以以某种方式创建仅允许一个特定包ID的意图的意图过滤器吗?
Can I somehow make an intent filter that only allows intents for one specific package ID?
推荐答案
尝试以下操作.
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"
android:sspPrefix="com.acme.myapp" />
</intent-filter>
This matches with the corresponding API call here.
这篇关于针对特定软件包的PACKAGE_ADDED的意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文