0

When I get response from c2dm there is an error in intent object req code is:

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

and when I get response there is an error:

public void onReceive(Context context, Intent intent) 
{
    if (intent.getStringExtra("error") == null) 
    {
        System.out.println("Error in registration ");
    }
}

if() condition is true why?

what are possible reasons for this error?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • I dont think there is an error because it is saying error = null and does not contain anything – FabianCook Jun 07 '12 at 09:37
  • when there is no error at that time you will get error parameter value null in response.so instead of intent.getStringExtra("error") == null you can put intent.getStringExtra("error") != null – Jay Thakkar Jun 07 '12 at 09:46

1 Answers1

0

From getStringExtra() documentation:

Returns the value of an item that previously added with putExtra() or null if no String value was found.

Maybe you want to test whether the string is not null?

if (intent.getStringExtra("error") != null) {
        System.out.println("Error in registration ");
}
nuala
  • 2,681
  • 4
  • 30
  • 50