title: Navigate to parent activity in java code in android
body: <p>I have created a adapterview along with bottomnavigation view in my code.
  This is the parent activity i have used for all my naviagtion views</p>
  
  <pre><code>&lt;activity android:name=".activity.patient.painpoint.PainPointBackView"
             android:parentActivityName=".activity.patient.assessment.PatientAssessmentActivity" /&gt;  
  </code></pre>
  
  <p>This is the adapter view which i have given as parentActivity for all the tabs</p>
  
  <p>[![adapter view][1]][1]</p>
  
  <p>This is one of the tab which i used,</p>
  
  <p>[![tab view][2]][2]</p>
  
  <p>How to navigate to the parent activity i.e, Adapter view when i clicked "assessment" icon from tab view. If i use onbackpressed()  it is taking to the another tab. I dont need to call using intent since it is a adapter i need to pass all the values again. Is there any way calling Parent activity from java code(PatientAssessmentActivity.class) and if i press toolbar back button it is navigating to parent activity. i need this to happen when i click assessment tab icon.</p>
  
  <p>This is the code i have used,</p>
  
  <pre><code>private void setupNavigationView() {
          BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
          Menu menu = bottomNavigationView.getMenu();
          MenuItem menuItem = menu.getItem(2);
          menuItem.setChecked(true);
  
          assessment = realm.where(Assessment.class).equalTo("patient_id", patientID).findFirst();
          Log.v(Constants.TAG, "addsdsds " + assessment);
  
          bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
              @Override
              public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  
                  switch (item.getItemId()) {
                      case R.id.action_assessment:
                      **here i need to navigate to parent activity**
                          break;
                      case R.id.action_front:
                          Intent intent = new Intent(PainPointBackView.this, PainPointFrontView.class);
                          intent.putExtra("patient_id", assessment.getPatient_id());
                          intent.putExtra("assessment_id", assessment.getId());
                          startActivity(intent);
                          break;
                      case R.id.action_back:
                          break;
                      case R.id.action_left:
                          Intent intent2 = new Intent(PainPointBackView.this, PainPointLeftView.class);
                          intent2.putExtra("patient_id", assessment.getPatient_id());
                          intent2.putExtra("assessment_id", assessment.getId());
                          startActivity(intent2);
                          break;
                      case R.id.action_right:
                          Intent intent3 = new Intent(PainPointBackView.this, PainPointRightView.class);
                          intent3.putExtra("patient_id", assessment.getPatient_id());
                          intent3.putExtra("assessment_id", assessment.getId());
                          startActivity(intent3);
                          break;
                  }
  
                  return false;
              }
          });
      }
  </code></pre>