Android应用更新广播 [英] Android app update broadcast
本文介绍了Android应用更新广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,即时通讯正在做一些事情,要求我知道何时更新设备上的另一个应用程序.所以我的问题很简单,可以说YouTube或Spotify在应用程序更新时发送广播,如果是的话,我需要使用broadcastReceiver接收什么.
So, im working on something that requires me to know when another application on the device is being updated. So my question is quite simple, does lets say YouTube or Spotify send a broadcast when the application is updating, and if so, what do i need to catch with my broadcastReceiver.
推荐答案
您的意图过滤器应类似于:
Your intent filter should be like:
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
您的BroadcastReceiver中的onReceive方法应为:
And onReceive method from your BroadcastReceiver should be:
@Override
public void onReceive(Context context, Intent intent) {
Uri data = intent.getData();
if (data.toString().equals("package:" + "com.target.package") {
// action to do
}
}
这篇关于Android应用更新广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文