Gmail app uses pushing, not polling. I suggest using this technique instead, polling is a battery killer in mobile devices To implement pushing, take a look at C2DM If you still want to poll, the recommended way would be to set up a periodic alarm in the AlarmManager.
Gmail app uses pushing, not polling. I suggest using this technique instead, polling is a battery killer in mobile devices. To implement pushing, take a look at C2DM.
If you still want to poll, the recommended way would be to set up a periodic alarm in the AlarmManager.
1 Or, consider Urban Airship or Xtify as commercial services offering similar solutions to C2DM. – CommonsWare May 19 at 0:16 @CommonsWare One thing to note is that if everyone implements their own pushing service, then the whole point is lost. I think we should stick to C2DM whether we it like it or not.
– aromero May 19 at 0:23 "One thing to note is that if everyone implements their own pushing service, then the whole point is lost. " -- you are welcome to your opinion. C2DM is a Google Labs beta project and therefore may lack the support and service level guarantees that some companies may wish.
– CommonsWare May 19 at 0:27 Awesome, thanks for the comments all! Loving the quick responses. In my app there is no unique data per user, each phone is polling to see if some universal info has changed.So not sure if push per device is the right solution here.
The AlarmManager looks great. Thanks! – Brian Armstrong May 19 at 0:54.
For a continuous, but not intensive poll like the one you comment (in the range of minutes between polls), I would implement it with AlarmManager. That way you make sure the phone wakes up to poll without the need for a wakelock, which would destroy your battery. As CommonsWare pointed out, you will still need to implement a wakelock for the time your code is executing, but you can release it as soon as the code is done, avoiding keeping the phone on while just waiting.
See his comment for an example on how to implement it. I would use a Service if, instead, you need faster polls during a shorter period of time (seconds between each poll), since setting alarms does not make sense to such short periods, and the battery would drain anyway.
1 You still need a WakeLock if the work you will do takes a material amount of time, as the alarm-invoked BroadcastReceiver cannot do much in onReceive(). See the WakefulIntentService for one wrapper around the WakeLock work: github. Com/commonsguy/cwac-wakeful – CommonsWare May 19 at 0:17 @CommonsWare you're right, but the point I wanted to make is that you do not need to keep the phone on when doing nothing.
BTW, that's a great demo. I will study it in detail. – Aleadam May 19 at 0:25 Oh, I agree completely -- an everlasting service just to watch the clock tick is an anti-pattern.
I was just quibbling a bit on the "without the need for a wakelock" part, that's all. – CommonsWare May 19 at 0:28 2 @CommonsWare I edited the post accordingly. – Aleadam May 19 at 0:42.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.