user1441805
user1441805

Reputation: 1

Android c2dm registration Unsuccessful

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", "[email protected]");

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?

Upvotes: 0

Views: 72

Answers (1)

nuala
nuala

Reputation: 2688

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 ");
}

Upvotes: 0

Related Questions