@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    finish();
  return true;
default :
return super.onOptionsItemSelected(item);
}
}

@ Override public boolean onOptionsItemSelected ( MenuItem item ) { switch ( item . getItemId ( ) ) { case android . R . id . home : finish ( ) ; return true ; default : return super . onOptionsItemSelected ( item ) ; } }
finishes the activity when the up button is pressed on the action bar .
