Skip to content Skip to sidebar Skip to footer

Handle Google C2dm Intents In A Service?

If I set up my Android Manifest XML file correctly, can I handle C2DM intents (REGISTRATION and RECEIVE) in a regular service, rather than a broadcast receiver? Clearly, the applic

Solution 1:

Quote from Google: An application on an Android device doesn’t need to be running to receive messages. The system will wake up the application via Intent broadcast when the the message arrives, as long as the application is set up with the proper broadcast receiver and permissions.

So, no. The only way to receive the messages is within a broadcast receiver. This is no big deal. Normally you receive the message and then you call a service. Google even provides you with an standard implementation. The Google IO session Android + App Engine: A Developer’s Dream Combination uses a wizard (see below for the installation) to generate the code.

Search for C2DMBaseReceiver, C2DMBroadcastReceiver and C2DMessaging for example in the ChromeToPhone code: all you have to do with these 3 classes is to provide a class C2DMReceiver which inherits from C2DMBaseReceiver and set up the manifest.

Update Google bloggt about Client Login key expiration. Therefore I expected that the plugin gets updated to include source which deals with that. Compared to the session video above some things changed. First you have to install the android wizard extra (it is not part of the Google plugin): Eclipse wizard installation Then as described in the video you have to use this wizard:new project In the generated project you can find c2dm.jar and c2dm-sources.jar. These files are spreaded all over the internet, but don't have a home location to download the latest version. So you have to generate them via the wizard. The source doesn't include a version comment and doesn't deal with the key expiration issues.

Solution 2:

No, but you can receive the broadcast in a broadcast receiver and then start a service from that.

Post a Comment for "Handle Google C2dm Intents In A Service?"