Take the 2-minute tour ×

I'm trying to use C2DM to trigger a push notification on my android phone, and have the user click the notification and launch a certain activity in the app. How can I pass this information along?

Currently I'm doing the following:

        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager 
            = (NotificationManager) getSystemService(ns);

        int icon = R.drawable.notification23;

        notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL;  

        Context appContext = getApplicationContext();
        Intent notificationIntent = new Intent(this, RequestDialogActivity.class);          
                | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        notificationIntent.putExtra(LocationHandler.KEY_ORIGINATOR, number);

        notification.setLatestEventInfo(appContext, contentTitle, contentText, contentIntent);

        final int id = 1;

        mNotificationManager.notify(id, notification);

I'm trying to store state by calling putExtra on the notificationIntent, but the new activity always has a null savedInstanceState Bundle. How can I pass information along?

share|improve this question
What exactly have you tried and what doesn't work? –  user658042 Nov 20 '11 at 21:35
add comment

1 Answer

up vote 1 down vote accepted

the extras you set in the intent have to be retrieved by the getIntent().getExtras() the savedInsanceState is more about retrieve the state when the application have been closed by the system and you want to recover the same state that user saw last time.

share|improve this answer
add comment

Your Answer


