安卓:更新/刷新正在运行的服务 [英] Android: Update / Refresh a running service
问题描述
我想更新我的正在运行的服务,所以我可以举例来说,当周的当前日期是星期一,它做了通知,在一定时间内,它的星期一,而当它的星期二它做通知它的星期二等...
问题是,如何让我的正在运行的服务进行刷新或更新,以便它可以从压延每天接收更新的一天吗?
我应该怎么使用? TimerTask的软件包(如何)?或者让一个线程还是什么?
如果有,请一个例子或逻辑code为解决这样的事情,如果你贴在这里这将是伟大的...
谢谢你。
I want to update my running service so I can for example, when the current day of the week is "Monday", it do a notification in a certain time that it's "Monday", and when it's "Tuesday" it do a notification that it's "Tuesday" and so on... The problem is, how to make my running service be refreshed or updated so that it can receive the updated day from the calender everyday? What I should use? TimerTask package (How)?, or make a Thread or what? and please if there is an example or a logic code for solving something like this it will be great if you posted it here... Thanks.
推荐答案
在广播接收器
添加到您的服务上,使用报警 AlarmManager
为一定时间星期一,这样,当警报响起时启动你的服务的广播接收器和接收器里面可以设置为第二天报警。
Add a Broadcast receiver
to your service, set an alarm using AlarmManager
for that certain time for Monday, so that when the alarm goes off it starts the broadcast receiver of your service and inside the receiver you can set the alarm for the next day.
要添加广播接收机,以服务见这
To add broadcast receiver to service see this
这篇关于安卓:更新/刷新正在运行的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!