Kushan
Kushan

Reputation: 5984

Broadcast receiver does not get MY_PACKAGE_REPLACED intent

As per the Android O developer preview, we can no longer use the PACKAGE_REPLACED intent to use with a receiver declared inside the manifest.

The alternative is MY_PACKAGE_REPLACED. But this intent does not seem to fire when i update the app via android studio after code changes. Whereas the old broader intent always fired properly.

    <receiver
        android:name=".Receivers.BootEventReceiver"
        android:exported="true"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
        </intent-filter>
    </receiver>

assume that the receiver itself just prints a log message in onReceive().

Googling suggested this seems to be some android manifest merger issue. But i really couldn't follow how to solve this.

Can someone point me in the right direction

Upvotes: 5

Views: 3353

Answers (1)

Kushan
Kushan

Reputation: 5984

Instead of having one receiver with two intent filters, i decided to make a separate receiver with MY_PACKAGE_REPLACED intent filter.

The receiver started working again. Hope this helps anyone interested

Upvotes: 5

Related Questions