0

I try to register to C2DM but it doesn't work. I included com.google.android.c2dm in my project. When I try to find com.google.android.c2dm.intent.REGISTER , it doesn't find anything :

String action = "com.google.android.c2dm.intent.REGISTER";
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

list.size() give 0. Any idea?

EDIT : mu manifest file contains the corrects permissions :

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Alexis
  • 16,629
  • 17
  • 62
  • 107

1 Answers1

0

You need to make sure you have the com.google.android.c2dm.permission.RECEIVE permission in your manifest file.

Also, I implemented registration using the following boilerplate

Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); 
registrationIntent.putExtra("sender", emailOfSender);
startService(registrationIntent);

You can refer to the full docs for basic setup.

Rob
  • 7,039
  • 4
  • 44
  • 75
  • edited question. And I use the same code but of course it triggers the error : SERVICE_NOT_AVAILABLE – Alexis Apr 11 '12 at 15:14
  • I'm assuming you have signed up c2dm? http://code.google.com/intl/sv-SE/android/c2dm/signup.html Also google suggests that error mean "The device can't read the response, or there was a 500/503 from the server that can be retried later. The application should use exponential back off and retry." – Rob Apr 11 '12 at 15:16
  • Yes I have signed up. I don't know if my registration is active yet but if the problem was my account, I guess I would get an error like AUTHENTICATION_FAILED or INVALID_SENDER – Alexis Apr 12 '12 at 06:43