Resuming a previous fragment onBackPressed()?
Change
@Override
public void onBackPressed()
{
getFragmentManager().popBackStack();
super.onBackPressed();
}
to
@Override
public void onBackPressed()
{
if(getSupportFragmentManager().getBackStackEntryCount() > 0)
getSupportFragmentManager().popBackStack();
else
super.onBackPressed();
}
and
fragmentManager.beginTransaction().replace(R.id.home_container, frag).commit();
to
fragmentManager.beginTransaction().replace(R.id.home_container, frag).addToBackStack(null).commit();
Add your fragment to back stack using addToBackStack(null)
like..
fragmentManager.beginTransaction().replace(R.id.home_container, frag).addToBackStack(null).commit();