Android: Broadcast ACTION_MY_PACKAGE_REPLACED never received
You probably figured this out already, but your action name in the manifest is wrong, instead of:
android.intent.action.ACTION_MY_PACKAGE_REPLACED
it should be
android.intent.action.MY_PACKAGE_REPLACED
You can also manually trigger the receiver using adb shell
for testing purposes:
adb shell am broadcast -a android.intent.action.MY_PACKAGE_REPLACED -n com.example.myapp/.ReInstallReceiver
I wanted to update this thread with a new answer, as I have found no posts that offer an updated solution for Android 7.0+ where this Intent
is now protected.
Go to Build -> Build APK
, and note the location that the .apk is stored.
Then, run in terminal:
adb install -r debugapp.apk
This will trigger the MY_PACKAGE_REPLACED
intent, since newer Android SDKs only allow the system to broadcast it.
Take into account that:
- A new version of your Application
- You should run adb install -r your new version apk,if you just run at Android Studio it won't receive this broadcast