title: Application Stopped while rotating the android device
body: <p>I have five tabs in my application say A,B,C,D and E.My problem is that application stopped while changing the tab from B to any other tabs and rotating the device into landscape mode or portrait mode. </p>
  
  <p>Error log is</p>
  
  <blockquote>
    <p>08-22 11:27:22.835: E/AndroidRuntime(5992): FATAL EXCEPTION: main
    08-22 11:27:22.835: E/AndroidRuntime(5992): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nv.netmdapp1/com.nv.netmdapp1.Home}: java.lang.NullPointerException
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3351)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread.access$700(ActivityThread.java:123)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.os.Handler.dispatchMessage(Handler.java:99)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.os.Looper.loop(Looper.java:137)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.app.ActivityThread.main(ActivityThread.java:4424)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at java.lang.reflect.Method.invokeNative(Native Method)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at java.lang.reflect.Method.invoke(Method.java:511)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at dalvik.system.NativeStart.main(Native Method)
    08-22 11:27:22.835: E/AndroidRuntime(5992): Caused by: java.lang.NullPointerException
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at com.nv.netmdapp1.ScheduleDailyView.onActivityCreated(ScheduleDailyView.java:89)
    08-22 11:27:22.835: E/AndroidRuntime(5992):     at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)</p>
  </blockquote>
  
  <p>Java code given below.</p>
  
  <blockquote>
    <p>public void onActivityCreated(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onActivityCreated(savedInstanceState);
            dailyFragment = (SherlockFragment) Fragment.instantiate(appContext, AppointmentDailyView.class.getName(),arguments);
            weeklyFragment=(SherlockFragment) Fragment.instantiate(appContext, AppointmentWeeklyView.class.getName(),arguments);</p>
  </blockquote>
  
  <pre><code>    FragmentTransaction ft = getFragmentManager().beginTransaction();
      Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
      if(lastFrag!=null)
          ft.remove(lastFrag);
      ft.replace(R.id.ll_appointment_layout, dailyFragment);
      ft.commit();
  }
  @Override
  public void onClick(View view) 
  {
      FragmentTransaction ft = getFragmentManager().beginTransaction();
      Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
      if(lastFrag!=null)
          ft.remove(lastFrag);
      if(view==btnDaily)
          ft.replace(R.id.ll_appointment_layout, dailyFragment);
      else
          ft.replace(R.id.ll_appointment_layout, weeklyFragment);
      ft.commit();
  }
  </code></pre>
  
  <p>When clicking Tab C this part is executed.But while rotating the device control goes to onActivityCreated() of Tab B.
  Here null pointer exception occurring  line ScheduleDailyView.java:89 is associated with Tab B.But while rotating the device control goes from tab C and D to this file.What is the reason?</p>