Your SlideShare is downloading. ×
Android Cloud to Device Messaging with the Google App Engine
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Android Cloud to Device Messaging with the Google App Engine

11,416
views

Published on

Overview about Androids Cloud to Device Messaging (C2DM) and a short inside of the Google App Engine.

Overview about Androids Cloud to Device Messaging (C2DM) and a short inside of the Google App Engine.

Published in: Technology

2 Comments
12 Likes
Statistics
Notes
No Downloads
Views
Total Views
11,416
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
2
Likes
12
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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
  • 3. The challenge
    Mobile Phone
    Data in the Cloud
  • 4. Internet creates value for your application
  • 5. Getting the data
    Polling
    Pushing
  • 6. Polling is easy
    1.) Ask the server if new data is available2.) If new data is available download it3.) Sleep / wait 4.) Repeat 1.)
  • 7.
  • 8. Polling every 5 min can consume 10 % of your battery
  • 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
  • 12. C2DM Architecture
    Googles C2DM Server
    Android App
    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
  • 17. C2DM Architecture
    Sends notification message to device
    Reads the real data from server
  • 18. Building the app
  • 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"
  • 20. Your C2DMReceiver
    Gets the registration ID and send it to your server
  • 21. Permissions
  • 22. Register Googles Receiver
  • 23. Send registration ID to server
  • 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....
  • 26. Your Java application server
  • 27. from Guillaume Laforge and Patrick Chanezon http://www.slideshare.net/glaforge/google-app-engine-java-groovy-baby
  • 28. Writing Java Webs application is annoyingly hard...
  • 29. Google App Engine
    GAE allows you to host webapplications on the Google infrastructure.
    Scalable Infrastructure
  • 30. Google App Engine
    No Server maintenance
    Super easy deployment
  • 31. It automatically scales up and down
    Computing power over time
  • 32. App Engine Architecture
    Load Balancer
    App Engine FrontEnd
    App Engine FrontEnd
    App Engine FrontEnd
    AppServer
    AppServer
    AppServer
  • 33. GAE Key points
    Deployment is super simple
    Supports subset of JPA / JDO for persistence
    Scalable per definition
    Free to get started (significant volume)
  • 34. Receiving the registration ID
  • 35. Send out message
  • 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

×