I want to pull some data from a server every x minutes. IF the info contains certain information I would like to create a notification. I want this polling to happen even when the app is in the background, or the phone is asleep. I have a few questions about polling in android.
What is the best way to go about doing it? Should I use an
IntentService, an AlarmManager, something else?
How often should I be polling the data? I would like to keep it relatively often, say under every 10 minutes.
I would favour an AlarmManager
as I try not to run continuously running services unless I really need to but it does really depend on how you will be using it.
If it were me I would (based on the limited description) :-
AlarmManager
to fire in say 10 minutes.You'll want to use something like Cloud to Device Messaging (C2DM) (aka push notifications in the iPhone world)
A great tutorial can be found at http://blog.mediarain.com/2011/03/simple-google-android-c2dm-tutorial-push-notifications-for-android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With