title: BaseActivity extends activity first but another activities get nullpointerexception
body: <p>I want to create base activity for use every new activity, There is a fragment, which create 5 new intents. FourOne is first intent, this one works perfectly but others got nullpointerexception. How can i solve this problem?</p>
  
  <p>BaseActivity</p>
  
  <pre><code>public class BaseActivity extends ActionBarActivity {
       private DrawerLayout mDrawerLayout;
       private ListView mDrawerList;
       private ActionBarDrawerToggle mDrawerToggle;
       protected RelativeLayout _completeLayout, _activityLayout;
       // nav drawer title
       private CharSequence mDrawerTitle;
  
        // used to store app title
       private CharSequence mTitle;
  
        private ArrayList&lt;NavDrawerItem&gt; navDrawerItems;
       private NavDrawerListAdapter adapter;
  
        @Override
       protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_activity);
         //if (savedInstanceState == null) {
         //on first time display view for first nav item
        //displayView(0);
        // }
       }
  
        public void set(String[] menutitles,TypedArray menuIcons) {
        mTitle = mDrawerTitle = getTitle();
  
         mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
         mDrawerList = (ListView) findViewById(R.id.slider_list);
  
         navDrawerItems = new ArrayList&lt;NavDrawerItem&gt;();
  
         // adding nav drawer items
        if(menuIcons==null){
        for(int i=0;i&lt;menutitles.length;i++){
         navDrawerItems.add(new NavDrawerItem(menutitles[i])); 
        }}else{
         for(int i=0;i&lt;menutitles.length;i++){
          navDrawerItems.add(new NavDrawerItem(menutitles[i],menuIcons.getResourceId(i, -1))); 
         }
        }
  
         mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
  
         // setting the nav drawer list adapter
        adapter = new NavDrawerListAdapter(getApplicationContext(),
          navDrawerItems);
        mDrawerList.setAdapter(adapter);
  
         // enabling action bar app icon and behaving it as toggle button
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        // getSupportActionBar().setIcon(R.drawable.ic_drawer);
  
         mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
          R.drawable.ic_drawer, // 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) {
          getSupportActionBar().setTitle(mTitle);
          // calling onPrepareOptionsMenu() to show action bar icons
          supportInvalidateOptionsMenu();
         }
  
          public void onDrawerOpened(View drawerView) {
          getSupportActionBar().setTitle(mDrawerTitle);
          // calling onPrepareOptionsMenu() to hide action bar icons
          supportInvalidateOptionsMenu();
         }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
  
       }
  
  
        private class SlideMenuClickListener implements
         ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
          long id) {
  
  
  
         // display view for selected nav drawer item
         displayView(position);
        }
       }
  
       @Override
       public boolean onCreateOptionsMenu(Menu menu) {
        //getSupportMenuInflater().inflate(R.menu.main, menu);
        return true;
       }
  
       @Override
       public boolean onOptionsItemSelected(MenuItem item) {
  
        if (item.getItemId() == android.R.id.home) {
         if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
          mDrawerLayout.closeDrawer(mDrawerList);
         } else {
          mDrawerLayout.openDrawer(mDrawerList);
         }
        }
  
        return super.onOptionsItemSelected(item);
       }
  
       /***
        * Called when invalidateOptionsMenu() is triggered
        */
       @Override
       public boolean onPrepareOptionsMenu(Menu menu) {
        // if nav drawer is opened, hide the action items
        // boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
        // menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
        return super.onPrepareOptionsMenu(menu);
       }
  
       /**
        * Diplaying fragment view for selected nav drawer list item
        * */
       private void displayView(int position) {
        // update the main content by replacing fragments
  
  
  
           switch (position) {
  
  
           case 0:
  
                 Intent intent = new Intent(this, FourOne.class);
                 startActivity(intent);
                 finish();
                 break;
                case 1:
                 Intent intent1 = new Intent(this, FourTwo.class);
                 startActivity(intent1);
                 finish();
                 break;
                case 2:
                 Intent intent2 = new Intent(this, FourThree.class);
                 startActivity(intent2);
                 finish();
                 break;
                case 3:
                 Intent intent3 = new Intent(this, FourFour.class);
                 startActivity(intent3);
                 finish();
                 break;
                case 4:
                 Intent intent4 = new Intent(this, FourFive.class);
                 startActivity(intent4);
                 finish();
                 break;     
                default:
                           break;
        }
  
        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        mDrawerList.setSelection(position);
        mDrawerLayout.closeDrawer(mDrawerList);
       }
  
       @Override
       public void setTitle(CharSequence title) {
        mTitle = title;
        getActionBar().setTitle(mTitle);
       }
  
       /**
        * When using the ActionBarDrawerToggle, you must call it during
        * onPostCreate() and onConfigurationChanged()...
        */
  
       @Override
       protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
       }
  
       @Override
       public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Pass any configuration change to the drawer toggls
        mDrawerToggle.onConfigurationChanged(newConfig);
       }
      }
  </code></pre>
  
  <p>first  activity, this one works</p>
  
  <pre><code>    public class FourOne extends BaseActivity {
  
  
      private String[] menutitles;
      private TypedArray menuIcons;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.four_one);
  
  
  
          menutitles = getResources().getStringArray(R.array.titlestwo); // load titles from strings.xml
  
          menuIcons = getResources()
                          .obtainTypedArray(R.array.iconstwo);//load icons from strings.xml
  
  
  
          set(menutitles, menuIcons);
  
      }
  
  
  
  }
  </code></pre>
  
  <p>second activity</p>
  
  <pre><code>    public class FourTwo extends BaseActivity {
  
  
      private String[] menutitles;
      private TypedArray menuIcons;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.four_two);
  
  
  
          menutitles = getResources().getStringArray(R.array.titlestwo); // load titles from strings.xml
  
          menuIcons = getResources()
                          .obtainTypedArray(R.array.iconstwo);//load icons from strings.xml
  
  
  
          set(menutitles, menuIcons);
  
      }
  
  
  
  }
  </code></pre>
  
  <p>logcat error</p>
  
  <pre><code>07-15 07:36:17.647: E/AndroidRuntime(1703): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sggsoftware.airsoftg/com.sggsoftware.airsoftg.FourTwo}: java.lang.NullPointerException
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.os.Handler.dispatchMessage(Handler.java:102)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.os.Looper.loop(Looper.java:136)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at java.lang.reflect.Method.invoke(Method.java:515)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at dalvik.system.NativeStart.main(Native Method)
  07-15 07:36:17.647: E/AndroidRuntime(1703): Caused by: java.lang.NullPointerException
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at com.sggsoftware.airsoftg.BaseActivity.set(BaseActivity.java:65)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at com.sggsoftware.airsoftg.FourTwo.onCreate(FourTwo.java:28)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.Activity.performCreate(Activity.java:5231)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
  07-15 07:36:17.647: E/AndroidRuntime(1703):     ... 11 more
  </code></pre>