Has anyone received Android MY_PACKAGE_REPLACED notifications?

梦想的初衷 提交于 2021-02-08 19:42:39

问题


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

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

Does anyone have insight into this problem?

My receiver definition:

    <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>

My 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”);
        }
    }
}

回答1:


According to the documentation:

It does not contain any additional data; to receive it, just use an intent filter for this action.

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



来源:https://stackoverflow.com/questions/22693894/has-anyone-received-android-my-package-replaced-notifications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!