views:

345

answers:

1

I'd like to create a service for Android that performs an operation once a day at a given time. What's an efficient way to accomplish this - I want to make sure I'm not draining the device battery since this service is idle 99% of the time.

+7  A: 

Not an Android expert, but http://www.androidguys.com/2009/04/02/wake-up-with-the-alarm/ seems to be what you are looking for

chburd
Agreed, and not just because I wrote that article. :-) AlarmManager will let you schedule work so your code can behave more like a cron job or Windows scheduled task -- wake up, run for a bit, then stop. Be sure to use a WakeLock so the device stays awake while you're trying to get work done. You can see a sample project implementing all of that here: http://github.com/commonsguy/cw-advandroid/tree/master/SystemServices/Alarm/
CommonsWare
Great stuff, will use it!
James Cadd