I have a Android app with one activity and two fragments. First fragment (`MainFragment`) show a list of "items" and second (`DetailsFragment`) display a item's details (very basic).

On the normal flow, the activity start and show first fragment and the second is shown when a item is clicked.

But the second fragment can be shown directly throught click on a notification (by putting extra arguments to the activity). 

```
String id = getIntent().getStringExtra("id");
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

if (id != null) {
    fragment = new DetailsFragment();
    Bundle args = new Bundle();
    args.putString("id", id);
    fragment.setArguments(args);
} else {
    fragment = new MainFragment();
}

ft.replace(R.id.main, fragment);
ft.commit();

```

In the second case, the problem is : How to open `MainFragment` when clicking back from `DetailsFragment` ? Actually the app finish because only the second fragment has been created.