Pushing bits from the cloud - Android and Push Notification (C2DM)   <ul><li>Lars Vogel – vogella.de </li></ul>
Independent Eclipse and Android Consultant and Trainer Team Lead and Android developer at SAP AG Maintains  http://www.vog...
Why is push good? Androids C2DM The server side
Data in the Cloud Mobile Phone The challenge
Internet creates value for your application
How to get data updates?
Getting the data Polling  Pushing
Polling is easy to implement Data? No Data? No Data? NO Data? NOOOOO!!! Data? Yes
 
An average battery has approx. 820 – 1150 mAh power
<ul><li>Polling every 5 min can consume 10 % of your battery  </li></ul>Polling every 5 min can consume 10 % of your batte...
Nobody  likes apps which reduce the battery life of the phone
Nobody  likes apps with stale data
Pushing Server informs the phone once new data is available
Androids C2DM
Why should a constant push connection consume less energy?
So why should that consume less battery? <ul><li>Connection is much cheaper then sending data </li></ul><ul><li>.... and M...
Cloud to Device Messaging Available for Android 2.2 (Beta – Invite only) Requires the Market available on the device Use e...
What components do you need?
Android App
Googles C2DM Server
Your application server
Trust - Everyone needs to know each other
Registration of the Server with Google Googles C2DM Server Your application server HTTP POST Token
Registration of the mobile device Googles C2DM Server Android App Request registration ID Unique registration ID Server mi...
Let my server know Android App Sends Registration ID to server Server stores the registration ID
Now my server is registered with Google AND has at least one device it can send message to
C2DM is ready to be used
Sending messages New HTTP Post message with registration id and authentication token * 200 – ok (with id==ok) 404 – get no...
I hope Google treats my data confidential
Real Data is fetched from my server Sends notification message to device Reads the real data from server
Enforced by the message limit C2DM push can send 1024 bytes of data
Message Receiver Code...
Further points Best effort delivery: Google will try to deliver all messages but some might get lost  collapse_key  to ens...
Server implementation can be anything curl, PHP, Python, C#, Scala,....
Android Developers like Java the Programming language
Your Java application server
from Guillaume Laforge and Patrick Chanezon http://www.slideshare.net/glaforge/google-app-engine-java-groovy-baby
Deployment of Java web application is....
Google App Engine Scalable Infrastructure GAE allows you to host webapplications on the Google infrastructure.
Google App Engine <ul><li>No Server maintenance </li></ul><ul><li>Super easy deployment </li></ul>
It automatically scales up and down Computing power over time
GAE Key points <ul><li>Free to get started, ideal for prototyping  </li></ul><ul><li>Price was recently increased </li></u...
<ul><li>Caching </li></ul><ul><li>Channel API (push to client, comet) </li></ul><ul><li>URL Fetching </li></ul><ul><li>Mai...
Building the app
Help is available <ul><li>Google for „Android C2DM tutorial“ </li></ul><ul><li>Latest Google Plugin for Eclipse has a new ...
Summary  <ul><li>C2DM powerful and relatively simple to use </li></ul><ul><li>Google App Engine makes prototyping </li></u...
Picture Credits Add the prefix  http://www.sxc.hu/photo <ul><li>Elephant:  http://www.sxc.hu/photo/103473 </li></ul><ul><l...
Futher information C2DM Tutorial http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html Google App Engi...
<ul><li>For further questions: </li></ul><ul><li>[email_address] </li></ul><ul><li>http://www.vogella.de </li></ul><ul><li...
Upcoming SlideShare
Loading in …5
×

Android C2DM Presentation at O'Reilly AndroidOpen Conference

6,618 views

Published on

Explains how to use Android C2DM.

Published in: Technology, News & Politics

Android C2DM Presentation at O'Reilly AndroidOpen Conference

  1. 1. Pushing bits from the cloud - Android and Push Notification (C2DM) <ul><li>Lars Vogel – vogella.de </li></ul>
  2. 2. Independent Eclipse and Android Consultant and Trainer Team Lead and Android developer at SAP AG Maintains http://www.vogella.de Java, Eclipse and Android related Tutorials with ~30 000 visitors per day @vogella About me
  3. 3. Why is push good? Androids C2DM The server side
  4. 4. Data in the Cloud Mobile Phone The challenge
  5. 5. Internet creates value for your application
  6. 6. How to get data updates?
  7. 7. Getting the data Polling Pushing
  8. 8. Polling is easy to implement Data? No Data? No Data? NO Data? NOOOOO!!! Data? Yes
  9. 10. An average battery has approx. 820 – 1150 mAh power
  10. 11. <ul><li>Polling every 5 min can consume 10 % of your battery </li></ul>Polling every 5 min can consume 10 % of your battery
  11. 12. Nobody likes apps which reduce the battery life of the phone
  12. 13. Nobody likes apps with stale data
  13. 14. Pushing Server informs the phone once new data is available
  14. 15. Androids C2DM
  15. 16. Why should a constant push connection consume less energy?
  16. 17. So why should that consume less battery? <ul><li>Connection is much cheaper then sending data </li></ul><ul><li>.... and Market is anyhow holding a connection </li></ul>Connection Data transfer
  17. 18. Cloud to Device Messaging Available for Android 2.2 (Beta – Invite only) Requires the Market available on the device Use existing Google connections Use AlarmManager to keep the connection (Heartbeat)
  18. 19. What components do you need?
  19. 20. Android App
  20. 21. Googles C2DM Server
  21. 22. Your application server
  22. 23. Trust - Everyone needs to know each other
  23. 24. Registration of the Server with Google Googles C2DM Server Your application server HTTP POST Token
  24. 25. Registration of the mobile device Googles C2DM Server Android App Request registration ID Unique registration ID Server might send new registration ID
  25. 26. Let my server know Android App Sends Registration ID to server Server stores the registration ID
  26. 27. Now my server is registered with Google AND has at least one device it can send message to
  27. 28. C2DM is ready to be used
  28. 29. Sending messages New HTTP Post message with registration id and authentication token * 200 – ok (with id==ok) 404 – get no auth token 503 – Retry with backoff
  29. 30. I hope Google treats my data confidential
  30. 31. Real Data is fetched from my server Sends notification message to device Reads the real data from server
  31. 32. Enforced by the message limit C2DM push can send 1024 bytes of data
  32. 33. Message Receiver Code...
  33. 34. Further points Best effort delivery: Google will try to deliver all messages but some might get lost collapse_key to ensure that old messages are overritten Message limit per sender, approx. 200 000
  34. 35. Server implementation can be anything curl, PHP, Python, C#, Scala,....
  35. 36. Android Developers like Java the Programming language
  36. 37. Your Java application server
  37. 38. from Guillaume Laforge and Patrick Chanezon http://www.slideshare.net/glaforge/google-app-engine-java-groovy-baby
  38. 39. Deployment of Java web application is....
  39. 40. Google App Engine Scalable Infrastructure GAE allows you to host webapplications on the Google infrastructure.
  40. 41. Google App Engine <ul><li>No Server maintenance </li></ul><ul><li>Super easy deployment </li></ul>
  41. 42. It automatically scales up and down Computing power over time
  42. 43. GAE Key points <ul><li>Free to get started, ideal for prototyping </li></ul><ul><li>Price was recently increased </li></ul><ul><li>Supports subset of JPA / JDO for persistence </li></ul><ul><li>Lots of additional services </li></ul>
  43. 44. <ul><li>Caching </li></ul><ul><li>Channel API (push to client, comet) </li></ul><ul><li>URL Fetching </li></ul><ul><li>Mail </li></ul><ul><li>Instant Messaging (XMPP) </li></ul><ul><li>Image Manipulation </li></ul><ul><li>User Management </li></ul><ul><li>Background Tasks </li></ul><ul><li>Map (no Reduce) </li></ul><ul><li>XMPP (Chat) </li></ul><ul><li>Pull Tasks (new) </li></ul>API’s
  44. 45. Building the app
  45. 46. Help is available <ul><li>Google for „Android C2DM tutorial“ </li></ul><ul><li>Latest Google Plugin for Eclipse has a new wizard </li></ul><ul><li>http://code.google.com/eclipse/docs/appeng_android_install_setup.html </li></ul>
  46. 47. Summary <ul><li>C2DM powerful and relatively simple to use </li></ul><ul><li>Google App Engine makes prototyping </li></ul><ul><li>Lets hope C2DM leaves beta soon and have a reasonable price model…. </li></ul>
  47. 48. Picture Credits Add the prefix http://www.sxc.hu/photo <ul><li>Elephant: http://www.sxc.hu/photo/103473 </li></ul><ul><li>Mouse http://www.sxc.hu/photo/ 1097314 </li></ul><ul><li>Liquid http://www.sxc.hu/photo/ 1109534 </li></ul><ul><li>Happy jumping people /930008 </li></ul><ul><li>Beta /853828 </li></ul><ul><li>Despair /150108 </li></ul><ul><li>Broken Glass 1046397 </li></ul><ul><li>Old Computer http://www.sxc.hu/photo/1028528 </li></ul><ul><li>Person with remote http://www.sxc.hu/photo/ 485640 </li></ul><ul><li>Victory fingers 906072 </li></ul><ul><li>Guy with a tie 877661 </li></ul>
  48. 49. Futher information C2DM Tutorial http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html Google App Engine Tutorial http://www.vogella.de/articles/GoogleAppEngineJava/article.html Chrome to Phone Example http://code.google.com/p/chrometophone/
  49. 50. <ul><li>For further questions: </li></ul><ul><li>[email_address] </li></ul><ul><li>http://www.vogella.de </li></ul><ul><li>http://www.twitter.com/vogella </li></ul>Thank you

×