public boolean onSupportNavigateUp ( ) { Intent upIntent = getSupportParentActivityIntent ( ) ; if ( upIntent != null ) { if ( supportShouldUpRecreateTask ( upIntent ) ) { TaskStackBuilder b = TaskStackBuilder . create ( this ) ; onCreateSupportNavigateUpTaskStack ( b ) ; onPrepareSupportNavigateUpTaskStack ( b ) ; b . startActivities ( ) ; try { ActivityCompat . finishAffinity ( this ) ; } catch ( IllegalStateException e ) { // This can only happen on 4.1+, when we don't have a parent or a result set. // In that case we should just finish(). finish ( ) ; } } else { // This activity is part of the application's task, so simply // navigate up to the hierarchical parent activity. supportNavigateUpTo ( upIntent ) ; } return true ; } return false ; }
This method is called whenever the user chooses to navigate Up within your application s activity hierarchy from the action bar .