简体   繁体   中英

How to make an alarm that works independent of the app itself

I have a list of items that the user can set timed reminders on and I need the alarm to notify and/or open the app during that time the user sets. I need this alarm to work even when the app has been terminated and possibly after a reboot. I have found many tutorials and examples but I'm not sure I looking in the right places.

Tutorials I have read already

Tutorial 1

Tutorial 2

Tutorial 3

EDIT: Not looking to be super accurate if for some reason it has drawbacks. I mean I'd like it be as accurate as possible, but I can allow for five minute windows if necessary. I can probably account for that once I know what I am doing.

It depends on how accurate you would like it to be. Tutorial 1 talks about services which as a "start-sticky" mode. This will allow them to always be running. This could potentially be accurate down to the second because you implement the timing mechanism yourself.

Tutorial 2 is probably the best option because it uses less battery power. Basically the alarm api will wake up and notify your app when the time passes. The only downside is that google makes no guarantee that the alarm will happen at the exact time specified, usually it is, but sometimes it will happen 3-5 seconds late.

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