Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Which one is best for continuous/time-wise server updates?</p> </blockquote> <p>depends if your app suppose to run in background / foreground at that time:</p> <p>let's say you are scheduling <code>Runnable</code> via handler to 15 minutes from now.<br> if the user will "close" all running activities, the system will probably kill your process if it not running any foreground services/activities after a while to reclaim memory. in that case - your <code>Runnable</code> will never be executed.<br> if you want to continuously poll for server updates even when the user navigates away from your app - this option is obviously not good for you. if you choose to update server like that - at least do it from a started <code>Service</code> context- that way your Handler reference will stay allocated even when user navigates from one screen to another...</p> <p>on the other hand - providing pending intent to <code>AlarmManager</code> insures that no mater if your process is alive or not - the intent provided to the <code>AlarmManager</code> will wake up your app (and the Service / Activity / broadcast) you provided with the pending intent.</p> <p>about your question - I think that <strong>none of the two</strong> are good solution to get server updates: </p> <p>the user probably have 10-20 applications (such Facebook/Twitter/Whattsap/Viber/Google+...) installed on his device which getting updates from server. imagine that each one of them wake up in some different time interval, opens internet connections, consuming lot's of precious battery life and band-width. <strong>that's crazy!</strong> your device will never "sleep", all process will be opened all the time, internet cellular radio transmission also. the battery will rich to 0% very fast! </p> <p>the right think to do is to use the GCM API. it requires also server side implementation, but the general idea is that the responsibility to wake up your application when there is a new data passes to the server's side, and by that -the android application don't need to poll for updates. it just get notified (and wake up if the process not alive) when the server notified you. in case you'll wonder - this is how it works - <a href="https://stackoverflow.com/questions/11508613/how-does-push-notification-technology-work-on-android/11508811#11508811">How does push notification technology work on Android?</a></p> <p>I advice you to read about it - <a href="http://developer.android.com/google/gcm/index.html" rel="nofollow noreferrer">http://developer.android.com/google/gcm/index.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload