如何安排我的 android 应用程序每小时做某事

如何安排我的 android 应用程序每小时做某事

问题描述:

我希望我的应用程序每小时访问一次数据库并从表中读取下一条记录,然后更新 desctop 小部件并发送通知.我知道有一个 AlarmManager,我可以用它来注册我的意图,但是当手机关闭或重新启动时它们会被删除.

I want my app to access database every hour and read next record from the table then update desctop widget and send notification. I know that there is AlarmManager which I can use to register my Intents but they are deleted when the phone is turned off or rebooted.

是否有任何其他 android 类/服务即使在我重新启动手机时也会持续更新我的应用程序?

Is there any other android class/service that I would update my application continuously even when I reboot my phone?

谢谢,

看看android sdk提供的demo应用

take a look at the demo applications provided with android sdk

http://developer.android.com/samples/RepeatingAlarm/index.html

查看AlarmService_Service 触发警报后服务的实现

the look at AlarmService_Service for the implementation of the service once the alarm has been triggered