title: Display back button of action bar is not going back in Android
body: <p>I am developing an Android app. I am using ActionBar with AppCompactActivity. In my app, I add back button to action bar. But when I click on it, it is not going back to the previous activity. For example, I start activity 2 from activity 1. Activity 2 contains action bar with back button. But when I click on action bar back button of activity 2, it is not going back to activity 1. </p>
  
  <p>This is how I set action bar for activity 2:</p>
  
  <pre><code>public class EditProfileActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.edit_profile);
          Toolbar toolbar = (Toolbar)findViewById(R.id.profile_action_toolbar);
          setSupportActionBar(toolbar);
          setTitle("Edit Profile");
          ActionBar actionBar= getSupportActionBar();
          actionBar.setDisplayHomeAsUpEnabled(true);
      }
  }
  </code></pre>
  
  <p>This is how I started activity 2 from activity 1:</p>
  
  <pre><code>Intent i = new Intent(MainActivity.this,SecondActivity.class);
                      startActivity(i);
  </code></pre>
  
  <p>It is not going back when I click this button</p>
  
  <p><a href="https://i.stack.imgur.com/hrxKR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hrxKR.png" alt="enter image description here"></a></p>
  
  <p>Why it is not going back?</p>