I have 2 activities, A and B. Activity A consists of a fragment. For the notification click, I'm using TaskStackBuilder, calling nextIntent as B which has parentActivity as A. For the nextIntent, I'm setting Intent.FLAG_ACTIVITY_NEW_TASK flag.
The scenario is, B activity is in foreground, notification arrives and you click on it, Activity A gets destroyed, Activity B loads from onCreate. If I go back, Activity A's onCreate gets loaded, but for fragment commit call, I'm getting the following crash.
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:617)
Here's how I'm committing the fragment
EgFragment fragment = new EgFragment();
getSupportFragmentManager().beginTransaction().add(R.id.view, fragment).commit();
Any help to overcome this scenario.....