Search code examples
androidandroid-alarmsrepeatingalarm

Schedule daily alarm after app install


I want to execute a BroadcastReceiver once a day.

Scheduling an alarm when the device boots works well, but it requires the device to be rebooted at least once.

How can I schedule the alarm right after app install (and still persist the scheduling after reboot) ?


Solution

  • How can I schedule the alarm right after app install

    Wait for the user to launch one of your activities from the home screen, then schedule your alarm on the first run of your app.

    Until then, or until something else uses an explicit Intent to work with one of your app components, your app will not run, and so you have no opportunity to schedule an alarm.