Android - Having a service run every day at 4AM

Posted by Bara on Stack Overflow See other posts from Stack Overflow or by Bara
Published on 2010-06-11T05:33:08Z Indexed on 2010/06/11 5:43 UTC
Read the original article Hit count: 292

Hello everyone,

I would like to know the best practices for running a Service every day at 4AM.

The way I think I should be doing it is to create a new repeating alarm using AlarmManager and having it run the service at 4AM. Problem is, I'm not sure where to put the code to set the alarm.

Do I do it in my main activity as one of the first tasks in the OnCreate method? Do I do some funky stuff with BroadcastReceivers and intents? What happens when a user updates my app? What happens when a user restarts?

Any help with these questions would be much appreciated :) Sample code would be helpful as well!

Bara

© Stack Overflow or respective owner

Related posts about android

Related posts about broadcastreceiver