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