Skip to content Skip to sidebar Skip to footer

Android: Broadcast Action_my_package_replaced Never Received

My app runs a service which is terminated when the device reboots or the app is reinstalled (updated). I've added two broadcast receivers to catch those events - BOOT_COMPLETED an

Solution 1:

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

Solution 2:

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.

Solution 3:

ACTION EXPLAIN IMAGE

Take into account that:

  1. A new version of your Application
  2. You should run adb install -r your new version apk,if you just run at Android Studio it won't receive this broadcast

Post a Comment for "Android: Broadcast Action_my_package_replaced Never Received"