如何使用每个工作日运行的警报管理器设置警报
大家好,我正在使用警报管理器在特定时间点运行我的应用程序。我想在每个工作日(周一至周五)运行我的应用程序,所以您能告诉我如何执行此操作吗?
Hey guys I'm using alarm manager to run my application at specific point of time. I want to run my application on every weekdays ( Mon-fri ) so could you please tell me how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何使用
AlarmManager
触发基于工作日的警报。作为解决方法,您可以每天触发警报,然后在代码中检查今天是一周中的哪一天,并仅在您需要的日子执行操作吗?我有兴趣听到任何其他方法。
编辑
其实,你可以先定个每日闹钟吗?然后,当警报触发时,检查当天是否是星期五。如果是这样,请编写一个将在周一触发的新警报。当警报响起时,再次创建每日闹钟。感觉有点笨重,但会减少手机唤醒的次数。
您需要在用户重新启动手机时处理该情况,并确保重新创建设置的任何闹钟。
I don't know of a way to use the
AlarmManager
to trigger weekday based alarms. As a workaround, can you trigger the alarm every day, then in your code check what day of the week it is, and only perform your actions on the days you require?I'd be interested to hear any other approaches.
EDIT
Actually, could you set a daily alarm first. Then when the alarm is triggered, check if the day is Friday. If so, write a new alarm that will trigger on Monday. When that goes off, create the daily alarm again. Feels a bit clunky, but would cause the phone to wake up less.
You will need to handle the case when the user restarts their phone and ensure that any alarm that was set is recreated.
所需要做的事情
该事件
管理员
应用或活动
http://justcallmebrian.com/?p=129
here is what needs to be done
the event
Manager
the app or activity
http://justcallmebrian.com/?p=129