@Override public boolean onOptionsItemSelected(MenuItem item){
  if (item.getItemId() == android.R.id.home) {
    NavUtils.navigateUpFromSameTask(this);
    return true;
  }
  return super.onOptionsItemSelected(item);
}

@ Override public boolean onOptionsItemSelected ( MenuItem item ) { if ( item . getItemId ( ) == android . R . id . home ) { NavUtils . navigateUpFromSameTask ( this ) ; return true ; } return super . onOptionsItemSelected ( item ) ; }
returns to the previous activity when the hardware back button is pressed
