YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Google cloud messaging - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 13 created 05/25/2016 by Udacity Robot.

  1. Inexact repeating alarms.
  2. Infinitely better than
    exact repeating alarms,
  3. but still far from ideal.
  4. The problem with any kind
    of repeating alarm
  5. is that it's still polling
    your server to check for updates.
  6. So the more frequently you poll,
    the fresher the data you can display
  7. but the higher the cost in battery life.
  8. You can pull as frequently
    to conserve battery
  9. but that just means
    your content will be stale
  10. for longer.
  11. You could just let the user decide
  12. the update frequency themselves,
  13. but then you lose the magic.
  14. If only there was a better way.
  15. Is such a thing possible?
    Yes it is.
  16. Google cloud messaging
    lets your server notify your app
  17. directly when there's data ready
    to be downloaded.
  18. Or it can even
    include the new data
  19. in the message payload itself.
  20. Using Google Cloud Messaging,
    you can send messages from
  21. your server to any installed instance
  22. of your app via the Google Cloud.
  23. As a result, you can stop polling,
  24. which will immediately
    improve battery life
  25. and also improve
    the freshness of your app.
  26. And instead, rely on your server
  27. notifying clients when
    there's data to sync.
  28. These messages can be simple tickles,
  29. that trigger a sync adapter
    by notifying your app
  30. that there is new data
    or need to download.
  31. Or you can include the new data
    within the message payload.
  32. In the sunshine example,
    we're using someone else's server.
  33. But even then,
    it may make sense to create
  34. your own middle tier
    that pulls the source
  35. and notifies your installed app instances
  36. when it notices a change.
  37. Now we're not going to set up
    a server in this lesson,
  38. but you can see the full details
  39. for using Google cloud messaging
  40. from the developer guide
    linked to instructor nets.