I am developing a simple fragment-based application using the FragmentActivity function. Each "screen" of the application is contained in a fragment, and all fragments are added to the layout of the container when the application starts.
fragMan = getFragmentManager();
FragmentTransaction ft = fragMan.beginTransaction();
ft.add(R.id.fragment_container, settingsFragment);
ft.add(R.id.fragment_container, mapFragment);
ft.add(R.id.fragment_container, tracksFragment);
ft.add(R.id.fragment_container, waypointsFragment);
ft.commit();
Transitions are performed by hiding the currently visible fragment, and then displaying the corresponding fragment.
ft = fragMan.beginTransaction();
ft.show(mapFragment);
ft.addToBackStack(null);
ft.commit();
Everything works fine, but when the "Back" button is pressed, the application exits, regardless of which screen is visible or what previous transactions have been added to the back stack.
, , , /, , .. , , , / , -, , " " .
, , ( ), -, , , . onBackPressed, , . , , ? , Nexus 7 Jelly Bean.