title: Android: Broadcast ACTION_MY_PACKAGE_REPLACED never received
body: <p>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 and ACTION_MY_PACKAGE_REPLACED.</p>
  
  <p>The ACTION_MY_PACKAGE_REPLACED receiver just doesn't seem to work. Here's what I have:</p>
  
  <p>AndroidManifest.xml:</p>
  
  <pre><code>    &lt;receiver android:name=".RebootReceiver"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
      &lt;receiver android:name=".ReInstallReceiver"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>RebootReceiver:</p>
  
  <pre><code>public class RebootReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          Logg.d("Reboot completed. Restarting service");
          context.startService(new Intent(context, MyService.class));
      }
  }
  </code></pre>
  
  <p>ReInstallReceiver:</p>
  
  <pre><code>public class ReInstallReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          Logg.d("App Upgraded or Reinstalled. Restarting service");
          context.startService(new Intent(context, MyService.class));
      }
  }
  </code></pre>
  
  <p>Running minSdk=16; Testing on Galaxy S3 running KitKat. Testing success by checking if my service is running in Settings/Applications, which it does on reboot, but not reinstall.</p>
  
  <p>I've taken into account notes from the following, which say that in Android Studio 1.0+, manifest mergers mean I can't combine two receivers into one class.  See <a href="https://stackoverflow.com/questions/12666734/action-my-package-replaced-not-received">ACTION_MY_PACKAGE_REPLACED not received</a> and <a href="https://stackoverflow.com/questions/24447663/android-manifest-merger-fails-for-receivers-with-same-name-but-different-content">Android manifest merger fails for receivers with same name but different content</a></p>