This presentation demonstrates the new capabilities of PowerPoint and it is best viewed in Slide Show. These slides are designed to give you great ideas for the presentations you’ll create in PowerPoint 2011!For more sample templates, click the File menu, and then click New From Template. Under Templates, click Presentations.
Introduction to google cloud messaging in android
Introduction to AndroidGoogle Cloud Messaging Amrit Sanjeev Organizer – Bangalore Android User Group
About me• Android hacker.• Organizer, Bangalore Android User Group ( www.blrdroid.org )• Research Engineer at Philips R&D
Bangalore Android User Group ( www.BlrDroid.org)• Largest open Android developer community in the country and second largest in the world.• Over 2500 members• 19 meetups• 3 hackathons• Active participation in events like Droidcon, Global Android Developer hackathon etc
What we will be discussing today. Why do we How it is What is implemented ? GCM? need GCM? Google Cloud Messaging
GCM definitionGCM stands for Google Cloud Messaging .It is a free service that allows developers to send data from third party servers to their applications running on android devicesHandles queuing of messages and delivery to the target application running on the target device.Intended use is not to send huge amount of data to the client device
Things to keep in mind Application on the android device DOES NOT need to be running to receive messages. Requires user to set up a Google account on the device. It is purely a routing component There is no guaranteed delivery of messages to the device .
Focus of GCM GCM stats are Ease of use. No available through No quotas. sign-up forms. the Android Developer Console. Rich set of new Battery efficiency. APIs
Difference between GCM and C2DM Simple API Key from Google APIs console page. Sender id is the project id rather than email address Supports data in JSON format and plain text
Difference between GCM and C2DM Multicast message support Multiple senders Messages have time to live ( 0 ~ 4 weeks ) eg. Expiring invitations Payload up to 4kb
The need to use GCMClient server architecture is the most common architecture . Most application do all the heavy lifting and processing at the servers and then use the processed data within the applications .Scalability & extensibilityMore computing power
The need to use GCMBackground process polling server for information at regular intervals is a bad design Battery performance System resource usage ( memory , CPU ) Complicated codingApplication does not need to be running in the background for receiving data messages.Lower cost and better tracking than SMS.
The need to use GCMLess coding required Not need to worry about queuing of messages Differed deliverySimpler application flow
The need to use GCM In a nutshell it makes application design much more simple, improves battery performance and makes better use of system resources .
Major components Your application server GCM servers Mobile device
Typical sequence of events The application server sends a message to GCM servers. Google queues The Android and stores the application message in case processes the the device is message offline. On the device, the system When the device broadcasts the is online, Google message to the sends the specified Android. message to the This wakes the device. Android application up.
Minimum requirements ( device side )Android 2.2 +Android market place should be installedEmulator with Google APIsInternet connectionGoogle account ( device version < 4.0.4 ).
Minimum requirements ( server side )HTTPS application server that should be Able to communicate with your client. Able to fire off HTTP requests to the GCM server. Able to handle requests and queue data as needed. For example, it should be able to perform exponential back off. Able to store the user device registration id .
Android application Copy the Add a Wire it up required broadcast in your libs receiver activity Make Add an changes Intent to the service manifest
Alternate Infrastructures• Alternative to GCM is required under following conditions Limited connectivity to internet services Security requirement Guaranteed delivery SLAs on delivery No quota limits• Downsides Complicated design Battery consumption on device is higher.
Thank youIn case you have more queries please feel free to contact Amrit.firstname.lastname@example.org (+91 97407 44557 ) @amsanjeev
Add required libsInstall Google Cloud Messaging for android using SDK manager.Copy gcm.jar from YOUR_SDK_ROOT/extras/google/gcm-client/dist to libs in your project folder
Changes to Manifest fileAdd <use-sdk … >Declare & use a custom permissionAdd additional permissions internet get_accounts wake_lock
Write Intentservice subclass of com.google.android.gcm.GCMBaseIntentService must contain a public constructor, Generally named my_app_package.GCMIntentService Override the following functions with appropriate logic onRegistered onUnRegistered onMessage onError onRecoverableError
Add boardcast receiver add a broadcast receiver with the custom permissions and following actions <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" />Should be defined in the manifest and not programmatically
Finally the activityCheckDevice ()CheckManifest()getRegistrationId()Register()