title: Android: NullPointerException at getActionBar
body: <p>I'm implementing navigation drawer sliding menu .getting <code>java.lang.NullPointerException</code> at the  </p>
  
  <pre><code>getActionBar().setDisplayShowHomeEnabled(true);
  getActionBar().setHomeButtonEnabled(true);
  </code></pre>
  
  <p>In my Application I have tried activity extended <code>Activity</code> and also <code>AppCompatActivity</code>.</p>
  
  <p>Here is my <code>onCreate</code> code</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
  
          mTitle = mDrawerTitle = getTitle();
  
          navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
          navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
          navDrawerItems = new ArrayList&lt;NavDrawerItem&gt;();
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1), true, "22"));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1), true, "50+"));
          navMenuIcons.recycle();
          mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
          adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
          mDrawerList.setAdapter(adapter);
         //abling action bar app icon and behaving it as toggle button
          getActionBar().setDisplayShowHomeEnabled(true);
          getActionBar().setHomeButtonEnabled(true);
          mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
  
                  R.drawable.menu_left, //nav menu toggle icon
                  R.string.app_name, // nav drawer open - description for accessibility
                  R.string.app_name // nav drawer close - description for accessibility
          )
          {
              public void onDrawerClosed(View view) {
                  getActionBar().setTitle(mTitle);
                  // calling onPrepareOptionsMenu() to show action bar icons
                  invalidateOptionsMenu();
              }
  
              public void onDrawerOpened(View drawerView) {
                  getActionBar().setTitle(mDrawerTitle);
                  // calling onPrepareOptionsMenu() to hide action bar icons
                  invalidateOptionsMenu();}
          };
  
          mDrawerLayout.setDrawerListener(mDrawerToggle);
          if (savedInstanceState == null) {
              // on first time display view for first nav item
              displayView(0);
          }
      }
  </code></pre>
  
  <p>Here is LogCat inforamtion </p>
  
  <pre><code> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tazeen.slidingmenu/com.example.tazeen.slidingmenu.MainActivity}: java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
              at android.app.ActivityThread.access$600(ActivityThread.java:130)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4745)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at com.example.tazeen.slidingmenu.MainActivity.onCreate(MainActivity.java:62)
              at android.app.Activity.performCreate(Activity.java:5008)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
              at android.app.ActivityThread.access$600(ActivityThread.java:130)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4745)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>