title: onSaveInstanceState null pointer
body: <p>I get this error once in a blue moon and can't seem to reproduce it or find out what the issue is:</p>
  
  <pre><code>java.lang.NullPointerException
         at com.example.mike.beerportfoliomaterial.BeerPage.onSaveInstanceState(BeerPage.java:221)
         at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:1933)
         at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1642)
         at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1710)
         at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:524)
         at com.example.mike.beerportfoliomaterial.MainDrawer2.onSaveInstanceState(MainDrawer2.java:193)
         at android.app.Activity.performSaveInstanceState(Activity.java:1253)
         at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1229)
         at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4175)
         at android.app.ActivityThread.access$1000(ActivityThread.java:174)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:146)
         at android.app.ActivityThread.main(ActivityThread.java:5731)
         at java.lang.reflect.Method.invokeNative(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:515)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
         at dalvik.system.NativeStart.main(NativeStart.java)
  </code></pre>
  
  <p>BeerPage java code is:</p>
  
  <pre><code>public class BeerPage extends Fragment  {
  
      public BeerPage(){}
  
      String beerId = "";
      String breweryId = "";
      SearchView searchView;
      private UiLifecycleHelper uiHelper;
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.beer_page, container, false);
          Spinner spinner = (Spinner) rootView.findViewById(R.id.statsSpin);
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(getActivity(),
                  R.array.beerpage, android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The drop down view
  
          spinner.setAdapter(adapter);
  
          spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; parentView, View selectedItemView, int position, long id) {
  
  
                  switch (position) {
                      case 0:
                          break;
                      case 1:
                          // do whatever stuff you wanna do here
                          Fragment Fragment_one;
                          FragmentManager man= getActivity().getSupportFragmentManager();
                          FragmentTransaction tran = man.beginTransaction();
                          Fragment_one = new TasteTags2();
                          tran.replace(R.id.main, Fragment_one);//tran.
                          tran.addToBackStack(null);
                          tran.commit();
                          break;
                      case 2:
                          Fragment Fragment_two;
                          FragmentManager mantwo= getActivity().getSupportFragmentManager();
                          FragmentTransaction trantwo = mantwo.beginTransaction();
                          Fragment_two = new TasteNotePage();
                          trantwo.replace(R.id.main, Fragment_two);//tran.
                          trantwo.addToBackStack(null);
                          trantwo.commit();
                          break;
                      case 3:
                          Fragment Fragment_three;
                          FragmentManager manthree= getActivity().getSupportFragmentManager();
                          FragmentTransaction tranthree = manthree.beginTransaction();
                          Fragment_three = new FoodPairingsPage();
                          tranthree.replace(R.id.main, Fragment_three);//tran.
                          tranthree.addToBackStack(null);
                          tranthree.commit();
                          break;
                      case 4:
                          Fragment Fragment_four;
                          FragmentManager manfour= getActivity().getSupportFragmentManager();
                          FragmentTransaction tranfour = manfour.beginTransaction();
                          Fragment_four = new ListPage();
                          tranfour.replace(R.id.main, Fragment_four);//tran.
                          tranfour.addToBackStack(null);
                          tranfour.commit();
                          break;
  
  
                  }
  
  
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; parentView) {
                  // your code here
              }
  
          });
  
  
          //body code goes here
  
          //get user information
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
          String userName = prefs.getString("userName", null);
          String userID = prefs.getString("userID", null);
          final String beerId = prefs.getString("beerID", null);
          breweryId = prefs.getString("breweryID", null);
          final String breweryName = prefs.getString("breweryName", null);
          final String styleName = prefs.getString("styleName", null);
          final String beerName = prefs.getString("lastBeer", null);
  
  
          TextView bt = (TextView)rootView.findViewById(R.id.beerBreweryName);
          bt.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // do whatever stuff you wanna do here
                  Fragment Fragment_one;
                  FragmentManager man= getActivity().getSupportFragmentManager();
                  FragmentTransaction tran = man.beginTransaction();
                  Fragment_one = new BreweryPage2();
  
  
  
  
                  ((ActionBarActivity)getActivity()).getSupportActionBar().setTitle(breweryName);
  
  
                  //set beer to get style from
                  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
                  SharedPreferences.Editor editor = preferences.edit();
                  editor.putString("breweryID",breweryId);
                  editor.commit();
  
                  tran.replace(R.id.main, Fragment_one);//tran.
                  tran.addToBackStack(null);
                  tran.commit();
  
              }
          });
  
  
          TextView bt2 = (TextView)rootView.findViewById(R.id.beerStyleName);
          bt2.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // do whatever stuff you wanna do here
  
                  ((ActionBarActivity)getActivity()).getSupportActionBar().setTitle(styleName);
  
  
                  Fragment Fragment_two;
                  FragmentManager man= getActivity().getSupportFragmentManager();
                  FragmentTransaction tran = man.beginTransaction();
  
                  //set beer to get style from
                  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
                  SharedPreferences.Editor editor = preferences.edit();
                  editor.putString("style",beerId);
                  editor.commit();
  
                  Fragment_two = new StylePage2();
                  tran.replace(R.id.main, Fragment_two);//tran.
                  tran.addToBackStack(null);
                  tran.commit();
  
  
  
              }
          });
  
  
  
          String url = "myURL";
  
  
          new GetBeerDataJSON2(getActivity(), beerId).execute(url);
  
  
          //facebook stuff
  
          uiHelper = new UiLifecycleHelper(getActivity(), null);
          uiHelper.onCreate(savedInstanceState);
  
  
          return rootView;
      }
  
      //facebook stuff
  
      @Override
      public void onResume() {
          super.onResume();
          uiHelper.onResume();
      }
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          uiHelper.onSaveInstanceState(outState);
      }
  
      @Override
      public void onPause() {
          super.onPause();
          uiHelper.onPause();
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          uiHelper.onDestroy();
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
              @Override
              public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
                  Log.e("Activity", String.format("Error: %s", error.toString()));
              }
  
              @Override
              public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
                  Log.i("Activity", "Success!");
              }
          });
      }
  
  
  
  
  
  
  }
  </code></pre>