1. Create google api project about GCM
2. Create server key. This api key will be used fot setting up server application.
Create App Engine project
1. Apply one project in app engine. Input project name and project url name.
Peoject url name will be used in Android application.
2. Download App engine SDK for JAVA
Set up Server Application
1. Android SDK Manager, install Extras > Google Cloud Messaging for Android Library.
2. In a text editor, edit PATH_TO_ANDOIRD_SDK/extras/google/gcm/
samples/gcm-demo-appengine/src/com/google/android/gcm/demo/server/ApiKeyInitializer.java and replace the existing text with the API key obtained above.3. In a shell window, go to the PATH_TO_ANDOIRD_SDK/extras/google/gcm/
samples/gcm-demo-appengine directory.4. ant -Dsdk.dir=PATH_APP_ENGINE_SDK/appengine-java-sdk-1.8.0/ compile
It will generate WebContent/. The code will be upload to App engine, so we don't need to launch server in our local side.
Upload Server Application to App Engine
1. From the appengine-java-sdk directory, run:
bin\appcfg.cmd update PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-appengine/WebContent/
2. Open http://appspot.com
3. It should show "no devices registered" page.
Set up Android Application
- Using a text editor, open
PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-client/src/com/google/android/gcm/demo/app/CommonUtilities.javaand set the proper values for theSENDER_IDandSERVER_URLconstants. - In a shell window, go to the
gcm-demo-clientdirectory. - Use the SDK's
androidtool to generate theantbuild files: android update project --name GCMDemo -p . --target android-16
4. ant clean debug
5. It will generate GCMDemo-debug.apk in bin/ folder
6. Install APK in devices.
7. Done.