public void onBackPressed(){
  if (!mFragments.popBackStackImmediate()) {
    finish();
  }
}

public void onBackPressed ( ) { if ( ! mFragments . popBackStackImmediate ( ) ) { finish ( ) ; } }
take care of popping the fragment back stack or finishing the activity as appropriate .
