Trying to implement google C2DM service.
registrationIntent.putExtra("app", PendingIntent.getBroadcast(context,0,new Intent(), 0));
registrationIntent.putExtra("sender","example@gmail.com");
context.startService(registrationIntent);
Almost every tutorial features this line of code. Is this a service that I must code? or does Android know how to handle this type of Intent. I am calling this method from a helper class with the default constructor. I pass the current Context to the this above method to create the registration Intent. Anyone have some insight on how this works or where my program will go?
No, you don’t have to write a service. You need to send an intent to a Google’s service. You’ve omitted the first line, where the intent is created, and that contains the service name. It’s something like this typically:
Intent registrationIntent = new Intent(“com.google.android.c2dm.intent.REGISTER”);
The line
com.google.android.c2dm.intent.REGISTERidentifies the Google’s service.Now, you still have to write the broadcast receiver that’ll receive the registration result (either an ID or error). And a receiver to receive the actual C2DM messages.