I have a very simple alarm app which needs to re-register it's alarms after phone reboots. However, seems like Android OS intent android.permission.RECEIVE_BOOT_COMPLETED
does not work properly - I am receiving BOOT_COMPLETED
every single time I update/deploy an app from Android Studio which is super odd and I believe incorrect behavior? This is my setup:
I declared a necessary permission in my AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I declared my Broadcast receiver in my AndroidManifest.xml
:
<receiver
android:name=".MyReceiver"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I listen to intents like this:
public class MyReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().startsWith("android.intent.action.BOOT_COMPLETED")) {
Log.i(this.TAG, "REBOOT"); // called every time I update an app
}
}
}
- Expected result: It should only happen after device reboot.
- Actual Result: I see "REBOOT" logged every single time I deploy an app on my device from Android Studio.
Anybody knows why such behavior happens? I can reproduce it on every device, every emulator, all the time.