I\'m trying to implement the behaviour described here, where a notification (or whatever) starts an \"internal\" activity in your app, and then when the user pressed back it
Intent displayIntent = new Intent(getApplicationContext(), TargetActivity.class);
displayIntent.putExtra("extra_id", "extra_key");
TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
stackBuilder.addParentStack(TargetActivity.class);
stackBuilder.addNextIntent(displayIntent);
stackBuilder.editIntentAt(1).putExtra("extra_id", "extra_key");
PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
getApplicationContext(), "123").setSmallIcon(R.drawable.logo)
.setContentTitle("GCM Notification")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Sample")).setContentText("sample text");
mBuilder.setContentIntent(contentIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(456, mBuilder.build());
stackBuilder.startActivities();
In addition to the above code also provide appropriate parent class names in your AndroidManifest.xml file.