WordPress Websites for Engineers: Elevate Your Brand
Android Cloud to Device Messaging with the Google App Engine
1. Cloud to Device Messaging(with Google App Engine) Lars Vogel Twitter: @vogella http://www.vogella.de
2. About me – Lars Vogel Works as independent Eclipse and Android Consultant and Trainer Also works for SAP AG as Product Owner in a Scrum team Maintains http://www.vogella.de Java, Eclipse and Android related Tutorials with ~20 000 visitors per day
9. Pushing Server informs the phone once new data is available Info triggeres a download of data
10. Cloud to Device Messaging Available for Android 2.2 (Beta – Invite only) Requires the Market available on the device Use existing Google connections Light-weight data will be send to the device Message is specific to your application (via permission) Use AlarmManager to keep the connection (Heartbeat)
11. C2DM – Building blocks Gmail User for the application registration Android Application Googles C2DM server Your Application Server
13. C2DM Architecture Request registration ID Unique registration ID Googles C2DM Server Android App Server might send new registration ID
14. C2DM Architecture Sends Registration ID to server Android App Server stores the registration ID
15. 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
16. Return 200 with error QuotaExceeded InvalidRegistration MessageTooBig MissingCollapseKey
19. Actually its relatively simple Google provides some util classes To register call: C2DMessaging.register(context, Your.Email@gmail.com) Register the Google provided C2DM broadcast receiver in your „AndroidManifest.xml“. Google receiver will forward the information it receives to: context.getPackageName() + ".C2DMReceiver"
24. Further points Best effort delivery: Google will try to deliver all messages but some might get lost Push can send 1024 characters -> not suited for big data, just notification
25. Server can be anything curl, php, For testing build your server also on the phone....
33. GAE Key points Deployment is super simple Supports subset of JPA / JDO for persistence Scalable per definition Free to get started (significant volume)
36. Funny: Cloud vrs. Mobile Cloud No Threads (Webworkers) No Access to file system Only Key / Value (+JPA, JDO) Time limited for requests 30 Mobile Threads Access to file system SQL Datebase Time limited for Activity 5 secs
37. Summary C2DM powerful and relatively simple to use Google App Engine makes the server site easy
38. Picture CreditsAdd the prefix http://www.sxc.hu/photo Elephant: http://www.sxc.hu/photo/103473 Mouse http://www.sxc.hu/photo/1097314 Liquid http://www.sxc.hu/photo/1109534 Beta 853828 Despair 150108 Old Computer http://www.sxc.hu/photo/1028528 Person with remote http://www.sxc.hu/photo/485640 Victory fingers 906072 Guy with a tie 877661
39. 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/
40. Thank you For further questions: Lars.Vogel@gmail.com http://www.vogella.de http://www.twitter.com/vogella
41. License & Acknowledgements This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License See http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en_US