I want to implement the back button to my app. I\'m using fragments that each show a different webview. Right now if I press the back button, it closes the app no matter where I
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
First first_act = new First();
fragmentTransaction.replace(R.id.fragment_container,
first_act);
fragmentTransaction.addToBackStack("first_act");
fragmentTransaction.commit();
Add these code in mainactivity , and then use this onbackpressed in fragment
@Override
public void onBackPressed() {
}