title: How provide Up navigation with toolbar's home button on v7 toolbar
body: <p>I have a toolbar in my activity ( <code>import android.support.v7.widget.Toolbar;</code> ) and I'm trying to provide Up navigation using its home button. What I have:</p>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;!-- ... --&gt;
  &lt;activity android:name=".SettingsActivity"
            android:label="@string/settings"
            android:parentActivityName=".MainActivity"/&gt;
  &lt;!-- ... --&gt;
  </code></pre>
  
  <p>view_toolbar.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:fitsSystemWindows="true"
      android:minHeight="?attr/actionBarSize"
      android:background="?attr/colorPrimary"
      android:elevation="4dp"&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>activity_settings.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;!-- Toolbar --&gt;
      &lt;include
          layout="@layout/view_toolbar" /&gt;
  
      &lt;!-- ... --&gt;
  </code></pre>
  
  <p>my onCreate method:</p>
  
  <pre><code>super.onCreate(bundle)
  setContentView(R.layout.activity_settings);
  
  // Set the toolbar
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  
  setSupportActionBar(toolbar);
  </code></pre>
  
  <p>So far I shouldn't have an up button and I don't. So we're fine. But when I tried to add it, I couldn't.</p>
  
  <p>First I tried this:</p>
  
  <pre><code>getSupportActionBar().setDisplayShowHomeEnabled(true);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  </code></pre>
  
  <p>Didn't work.
  Then I tried this (as shown <a href="https://stackoverflow.com/questions/26859841/homeasup-button-has-no-effect-in-android-4-2-2-with-appcompat-21-0-0?rq=1">here</a>):</p>
  
  <pre><code>toolbar.setNavigationOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
      Toast.makeText(ToolbarActivity.this, "Up clicked", 
          Toast.LENGTH_SHORT).show();
      NavUtils.navigateUpFromSameTask(ToolbarActivity.this);
  }
  });
  </code></pre>
  
  <p>I even tried a workaround I saw somewhere, involving creating a dummy menu and trying to get the event from <code>onOptionsItemSelected</code> (which is never called by the way).</p>
  
  <p>What can I do? What is the correct way to provide Up navigation through toolbar?</p>