有人收到过Android MY_PACKAGE_REPLACED通知吗? [英] Has anyone received Android MY_PACKAGE_REPLACED notifications?

查看:158
本文介绍了有人收到过Android MY_PACKAGE_REPLACED通知吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从没有收到MY_PACKAGE_REPLACED通知.如果将其更改为PACKAGE_REPLACED,则会收到预期的通知.

I never get the MY_PACKAGE_REPLACED notifications. If I change it to PACKAGE_REPLACED, I do get the expected notifications.

我的SDK级别为19,设备为4.0及更高版本.

My SDK level is 19 and the devices are 4.0 and above.

有人对此问题有见识吗?

Does anyone have insight into this problem?

我的接收者定义:

    <receiver android:name="com.jerome.applications.service.PackageReplacedReceiver">
        <intent-filter>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            <data android:scheme="package" />
        </intent-filter>
    </receiver>

我的接收者:

public class PackageReplacedReceiver extends BroadcastReceiver {
    private final String kMe = "PackageReplacedReceiver";
    @Override
    public void onReceive(final Context context, final Intent intent) {
        Log.d(kMe, "onReceive context: " + context + " intent: " + intent);

        if ((intent == null) || (context == null)) {
            Log.e(kMe, "onReceive got a null parameter");
        }
        else {
            Log.d(kMe, "onReceive starting to do some stuff");
        }
    }
}

推荐答案

根据文档:

它不包含任何其他数据;要接收它,只需为此操作使用一个意图过滤器.

所以我认为,如果您从意图过滤器中提取< data> 标记,它将起作用.

So I think if you pull out the <data> tag from your intent filter it will work.

这篇关于有人收到过Android MY_PACKAGE_REPLACED通知吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆