我在Android活动中显示视图,该活动通过http加载数据并通过线程导航视图。
完美的工作。但是当它正在加载数据并且我按回然后它已经崩溃了。我的错误代码如下。我还实现了onSaveInstanceState()和onRestoreInstanceState()。
需要, 感谢。
@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)