broadcastreceiver - Broadcast intent android.intent.action.BOOT_COMPLETED received every single time I runupdate the app. Why? -

I have a very simple alarm app which needs to re-register it's alarms after phone reboots. However

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744219279a4563701.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信