有没有人收到Android MY_PACKAGE_REPLACED通知?

时间:2014-03-27 16:40:28

标签: android-intent

我从未收到MY_PACKAGE_REPLACED通知。如果我将其更改为PACKAGE_REPLACED,我会收到预期的通知。

我的SDK级别为19,设备为4.0及以上。

有没有人对这个问题有所了解?

我的接收器定义:

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

1 个答案:

答案 0 :(得分:4)

根据文件:

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

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