I have an application which is supposed to retrieve data from a Website every x minutes. Something like a push service is not possible. After retrieving the data a notification should appeare at the info bar or what ever you call it. I was reading and reading and at first I thought I should do a new thread which contains a localservice. Than I found out about the AlarmManager and thought “woa” that should be even better since the AlarmManager is also using some kind of wake-up in order to run a given Intent while sleeping. So my final decision is to use an alarm which starts a service which is doing the data collection and notification every x minutes.
The questions I have are:
-
Is this really the best way to do it.
-
Does AlarmManager automatically start the service in a new thread? If not how do I do this. (Just create a new thread in which I initialize the alarm?)
You are confused about how to do it. You need all that things together.
AlarmManager fires the intent which starts the service(via BroadcastReceiver). Service creates new thread, inside which you can fetch data.