ekjyot
ekjyot

Reputation: 2227

android:how to open the app on clicking on push notification

I have implemented the push notifications using C2DM code in my project. It is showing push notifications But my problem is how to open the app on clicking on the push notification.

I am doing it like:

Intent intent = new Intent(context, BingoDiaryActivity.class);
        intent.putExtra("registration_id", registrationId);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        notification.setLatestEventInfo(context, "Registration", "Successfully registered",
                pendingIntent);
        notificationManager.notify(0, notification);

But it is not working

Can anyone helps me over this?

Thanks

Upvotes: 1

Views: 2413

Answers (1)

Jin35
Jin35

Reputation: 8612

I can't understand what's wrong with you code, but in my project works this - and clicking on notifier open my app:

n.setLatestEventInfo(context, "text", "text", 
        PendingIntent.getActivity(
                context, 
                0,
                context.getPackageManager().getLaunchIntentForPackage(context.getPackageName())
                       .putExtra("extra_name", extra), 
                0));

Upvotes: 1

Related Questions