code: public void navigateUp(Intent intent) {
          intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
          start(intent);
          finish();
      }
docs: Navigates up to specified activity in the back stack skipping intermediate activities