C2DM Android application.

To continue from my previous post, Google Cloud to device messaging for Android, I will walk through how to build and install the Android application.

First of all you will have to sign up for access to the service. You can do this from Googles sign-up page.

You will then have to enter the Google account id into the Constants class where you will find a constant called named C2DM_APPLICATION_SERVER_ID.

The application is using the Maven build system, utilising the maven-android plugin. This makes it very easy to build and install as long as you have Maven installed. You will need to connect your Android 2.2 device or start the emulator, then issue the following command in your shell:

For the device side this is pretty much it. When you have set up your server you can go ahead and start the application. You will be presented with a button which you click to register for receiving messages. When you then use the server to send a message you will see this being printed to the log.

  • Anonymous

    Thanks, the maven process didn't work for me with a very long error I couldn't understand. It would probably make sense to a maven person, but I'm from a different world. There was some MethodNotFoundException in there somewhere so I'm guessing there's an outdated api in use.

    Because your sample was so simple I got it working by creating an eclipse project and importing all the files into there.

  • Anonymous

    Also, onBind of your C2DMService never gets called... Does it work for you?

  • Anonymous

    Glad you have found it helpful.

    It was a long time ago that I wrote the articles. When I created the example it worked. However there may be boilerplate code in the Android app. Android is not one of my strengths.

    The Maven plugin has probably changed since the article was written and I also think there has been a couple more releases of Android.