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
An intent is a messaging object, a broadcast receiver is an app component. An intent is used to request some action from some app component, it could be a broadcast receiver, an activity or a service.
Sending Broadcast intents from the Activity Intent intent = new Intent(); intent. setAction("com. journaldev. CUSTOM_INTENT"); sendBroadcast(intent);
Android uses Broadcast Intents extensively to broadcast system events like battery-charging levels, network connections, and incoming calls. Broadcasting Intents is actually quite simple. Within your application component, construct the Intent you want to broadcast, and use the sendBroadcast method to send it.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With