简体   繁体   中英

How to setup alarms again after reboot

I am building an alarm clock application, then is purely dependent on alerting the user during the proper time an alarm is to go off. However, reading about AlarmManager, it appears that at device reboot, all alarms are removed.

As my app would then be rendered worthless if all the users alarms were erased, how can I prevent that from happening/ensure that all alarms are always in place whether reboot or not?

Have your application handle the ACTION_BOOT_COMPLETED intent to install alarms at boot:

Broadcast Action: This is broadcast once, after the system has finished booting. It can be used to perform application-specific initialization, such as installing alarms. You must hold the RECEIVE_BOOT_COMPLETED permission in order to receive this broadcast.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM