Repeating Alarm in Android

折月煮酒 提交于 2019-12-24 14:56:11

问题


What is the best way to implement repeating alarm in my android application? Every user selects a specific time and I want to notify them when this time approaches on daily bases. I have come across this, but I am wondering whether this is the best way?


回答1:


The alarm manager should meet your needs. There is no better way except for maybe having a server ping your client.

Since android really doesn't like things that repeat on a predictable interval, and since recent versions don't let you repeat on an exact fixed interval anyway, you'll need to schedule the alarm at the time you want, and then when that alarm fires, schedule a new one for the next day at the time you want.




回答2:


use

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarm_time,
                        intervel, pendingIntent);

in your activity



来源:https://stackoverflow.com/questions/32001783/repeating-alarm-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!