Upon pressing the back button, after opening the notification, the user is taken back to the Home screen instead of going back to the main page of the application. (Using a Samsung S5 with Android 5.0)
The notification is built and shown as follows:
NotificationManager mNotifyMgr =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(GcmMessageHandler.this, ListViewItemDetailActivity.class);
Bundle b = new Bundle();
//... put some data
resultIntent.putExtras(b);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(GcmMessageHandler.this);
stackBuilder.addParentStack(ListViewItemDetailActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(GcmMessageHandler.this)
.setContentTitle("Notification")
.setSmallIcon(R.drawable.common_signin_btn_icon_dark)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setContentIntent(resultPendingIntent)
.setPriority(0)
.setContentText(title);
mNotifyMgr.notify(mNotificationId++, mBuilder.build());
Also in the Manifest file, i have set the parentActivity as follows
<activity
android:name=".ListViewItemDetailActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>