Execute BOOT_COMPLETED action on first launch of app

325 views Asked by At

I am using AlarmManager to trigger a regular action of my app that should run whenever the device is on. Following the documentation I am receiving an intent of type android.intent.action.BOOT_COMPLETED to start the alarm whenever the device starts.

I am aware that the user needs to start the app before it can receive this intent as explained here and in many question on StackOverflow.

But when the user starts the app for the first time want to immediately set the alarm and not wait until the device reboots for the first time.

How can I trigger my alarm setup cleanly when the app is launched for the first time in addition to on BOOT_COMPLETED?

I guess could call the alarm setup in my launcher activity but this seems to bloat the Activity code and I don't want to execute it if the alarms have been setup at BOOT_COMPLETED already.

0

There are 0 answers