I am currently using an AlarmManager in my activity to start a service every X minutes.
It's seems to work but it looks as if the Service runs initially on the main thread which I believe to cause random ANRs. (this was determined using some code snippet to check the looper, the only true value returned is when the service starts (which then starts Asynctasks))
How can I use the AlarmManager to start the Service on its own thread?
Or should I be starting this repeating Service in some other way?
How can I use the AlarmManager to start the Service on its own thread?
AlarmManager
does not affect your threads. You need to arrange for your service to do its work on a background thread. The simplest way to do this is to extend IntentService
and put your work in onHandleIntent()
.