title: Null pointer exception on a navigation drawer in android app
body: <p>I'm following this tutorial:
  <a href="http://codetheory.in/android-navigation-drawer/" rel="nofollow">http://codetheory.in/android-navigation-drawer/</a></p>
  
  <p>When the app start I get:
  java.lang.RuntimeException: Unable to start activity ComponentInfo{pakage/pakage.MainActivity}: java.lang.NullPointerException
  ...
  Caused by: java.lang.NullPointerException
              at pakage.MainActivity.onPostCreate(MainActivity.java:138)</p>
  
  <p>line 138 is marked with a comment //line 138</p>
  
  <p>The code:</p>
  
  <pre><code>package net.udazz.udazz;
  
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.content.Context;
  import android.os.Bundle;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.widget.AdapterView;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  
  
  public class MainActivity extends AppCompatActivity {
  
      ListView mDrawerList;
      RelativeLayout mDrawerPane;
      private ActionBarDrawerToggle mDrawerToggle;
      private DrawerLayout mDrawerLayout;
  
      ArrayList&lt;NavItem&gt; mNavItems = new ArrayList&lt;NavItem&gt;();
  
      private WebView mWebView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mNavItems.add(new NavItem("Home", "Meetup destination", R.mipmap.ic_action_home));
          mNavItems.add(new NavItem("Preferences", "Change your preferences", R.mipmap.ic_action_settings));
          mNavItems.add(new NavItem("About", "Get to know about us", R.mipmap.ic_action_about));
  
          // DrawerLayout
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
  
          // Populate the Navigtion Drawer with options
          mDrawerPane = (RelativeLayout) findViewById(R.id.drawerPane);
          mDrawerList = (ListView) findViewById(R.id.navList);
          DrawerListAdapter adapter = new DrawerListAdapter(this, mNavItems);
          mDrawerList.setAdapter(adapter);
  
          // Drawer Item click listeners
          mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  selectItemFromDrawer(position);
              }
          });
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          mWebView = (WebView) findViewById(R.id.activity_main_webview);
  
          // Enable Javascript
          WebSettings webSettings = mWebView.getSettings();
          webSettings.setJavaScriptEnabled(true);
          mWebView.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
          mWebView.getSettings().setLoadWithOverviewMode(true);
          mWebView.getSettings().setUseWideViewPort(true);
  
          mWebView.loadUrl("http://page/");
  
          // Stop local links and redirects from opening in browser instead of WebView
          mWebView.setWebViewClient(new MyAppWebViewClient());
      }
  
      @Override
      public void onBackPressed() {
          if(mWebView.canGoBack()) {
              mWebView.goBack();
          } else {
              super.onBackPressed();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Pass the event to ActionBarDrawerToggle
          // If it returns true, then it has handled
          // the nav drawer indicator touch event
          if (mDrawerToggle.onOptionsItemSelected(item)) {
              return true;
          }
  
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
      /*
      * Called when a particular item from the navigation drawer
      * is selected.
      * */
      private void selectItemFromDrawer(int position) {
          Fragment fragment = new PreferencesFragment();
  
          FragmentManager fragmentManager = getFragmentManager();
          fragmentManager.beginTransaction()
                  .replace(R.id.mainContent, fragment)
                  .commit();
  
          mDrawerList.setItemChecked(position, true);
          setTitle(mNavItems.get(position).mTitle);
  
          // Close the drawer
          mDrawerLayout.closeDrawer(mDrawerPane);
      }
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          mDrawerToggle.syncState(); // line 138
      }
  }
  class NavItem {
      String mTitle;
      String mSubtitle;
      int mIcon;
  
      public NavItem(String title, String subtitle, int icon) {
          mTitle = title;
          mSubtitle = subtitle;
          mIcon = icon;
      }
  }
  class DrawerListAdapter extends BaseAdapter {
  
      Context mContext;
      ArrayList&lt;NavItem&gt; mNavItems;
  
      public DrawerListAdapter(Context context, ArrayList&lt;NavItem&gt; navItems) {
          mContext = context;
          mNavItems = navItems;
      }
  
      @Override
      public int getCount() {
          return mNavItems.size();
      }
  
      @Override
      public Object getItem(int position) {
          return mNavItems.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view;
  
          if (convertView == null) {
              LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              view = inflater.inflate(R.layout.drawer_item, null);
          }
          else {
              view = convertView;
          }
  
          TextView titleView = (TextView) view.findViewById(R.id.title);
          TextView subtitleView = (TextView) view.findViewById(R.id.subTitle);
          ImageView iconView = (ImageView) view.findViewById(R.id.icon);
  
          titleView.setText(mNavItems.get(position).mTitle);
          subtitleView.setText(mNavItems.get(position).mSubtitle);
          iconView.setImageResource(mNavItems.get(position).mIcon);
  
          return view;
      }
  }
  </code></pre>