本文介绍了PACKAGE_REMOVED和放大器;然后PACKAGE_ADDED与PACKAGE_REPLACED意图动作射击沿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有我想要做的就是更新我的每个安装及放列表;卸载但不会在包装更换。所以主要的问题是,安装和放大器;卸载意图是每个替换操作启动。
All I am trying to do is update my list on each Install & Uninstall but not on Package Replace .So the main problem is that Install & Uninstall intents are launched on each Replace action.
所以,为此,我实现了一个BroadcastReciever如下
SoFor this I have implemented a BroadcastReciever as below
<receiver android:name =".IntentReceiverTest.AppReciever">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
在每次更换我得到3广播用行动
On each Replace I get 3 broadcasts with actions
- 首先是 PACKAGE_REMOVED 这触发鸭preciever
- 然后在 PACKAGE_ADDED 这再次触发鸭preciever
- 然后几秒钟后的 PACKAGE_REPLACED 这再次触发鸭preciever
- First with PACKAGE_REMOVED which fires AppReciever
- then after PACKAGE_ADDED which again fires AppReciever
- And then after few seconds PACKAGE_REPLACED which again fires AppReciever
所以,请提出更好的办法只能赶上替换操作
So please suggest any better way to catch only Replace Action
或
办法停止$ P $由于PACKAGE_REMOVED和PACKAGE_ADDED pviously推出服务操作。
推荐答案
只是检查 intent.getBooleanExtra(Intent.EXTRA_REPLACING,FALSE)
:
if (!intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED) &&
intent.getBooleanExtra(Intent.EXTRA_REPLACING, false))
return;
这篇关于PACKAGE_REMOVED和放大器;然后PACKAGE_ADDED与PACKAGE_REPLACED意图动作射击沿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!