title: Error onSaveInstanceState in android
body: <p>I am displaying views in Android activity, which loads data through http and navigates views via thread.</p>
  
  <p>It is perfectly work well. But while it's loading data and I press back then it has been crashed. My error code is as below. I have also implemented onSaveInstanceState() and onRestoreInstanceState().</p>
  
  <p>Do needful,
  Thanks.</p>
  
  <pre><code>@Override
  public void onSaveInstanceState(Bundle savedInstanceState){     
      super.onSaveInstanceState(savedInstanceState);
  }
  
  @Override 
  public void onRestoreInstanceState(Bundle savedInstanceState){
      super.onRestoreInstanceState(savedInstanceState);
  }
   ------------------------------------------------------------------------------------------------
   java.lang.RuntimeException: Unable to pause activity {com.sample.android/com.sample.android.SampleActivity}: java.lang.NullPointerException
   at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3354)
   at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3311)
   at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3294)
   at android.app.ActivityThread.access$2500(ActivityThread.java:126)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
   at android.os.Handler.dispatchMessage(Handler.java:99) 
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:4633)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.NullPointerException
   at android.support.v4.view.ViewPager.onSaveInstanceState(ViewPager.java:507)
   at android.view.View.dispatchSaveInstanceState(View.java:6068)
   at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1180) 
   at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1184)
   at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1184)
   at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1184)
   at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1184)
   at android.view.View.saveHierarchyState(View.java:6051) 
   at com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1490)
   at android.app.Activity.onSaveInstanceState(Activity.java:1086)
   at com.yoke.android.SampleActivity.onSaveInstanceState(YokeActivity.java:352)
   at android.app.Activity.performSaveInstanceState(Activity.java:1036)
   at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1180)
   at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3336)
  </code></pre>