title: Why do i keep getting a NullPointerException while using AppCompatActivity to create a custom Action Bar in Android?
body: <p>I am relatively new to Android and have been going at this for about two days now and cannot find any solution. It seems that whenever I try to access my activity's action bar the app cannot find a compatible action bar. I suspect this is because of something that I am missing because of the relatively new AppCompatActivity update making the available theme incompatible with the Action Bar. </p>
  
  <p>Essentially, all I want to do is add the setDisplayHomeUpEnabled to my Action Bar.</p>
  
  <p>Here is my Activity:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu items for use in the action bar
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.snackbar, menu);
      return super.onCreateOptionsMenu(menu);
  }
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      addListenerOnButton();
      ActionBar actionBar = getSupportActionBar();
      actionBar.setDisplayHomeAsUpEnabled(true);
  }
  </code></pre>
  
  <p>My Action Bar:</p>
  
  <p></p>
  
  <pre><code>&lt;item android:id="@+id/action_search"
        android:icon="@drawable/padlock"
        android:title="@string/app_name"
        android:showAsAction="ifRoom"/&gt;
  &lt;item android:id="@+id/action_compose"
        android:icon="@drawable/padlock"
        android:title="@string/action_compose"
        android:showAsAction="ifRoom"/&gt;
  </code></pre>
  
  <p>
  My Manifest:
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.Passwords"
            android:versionCode="1"
            android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="16"/&gt;
      &lt;application android:label="@string/app_name" android:icon="@drawable/padlock"
              android:theme="@style/Theme.AppCompat.Light"&gt;
          &lt;activity android:name="MyActivity"
                    android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
                  android:name="Activity2"
                  android:parentActivityName="com.example.Passwords.MyActivity"
                  android:label="@string/second"&gt;
  
          &lt;/activity&gt;
  
  
      &lt;/application&gt;
  &lt;/manifest&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any help resolving this problem is appreciated.</p>