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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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