RuntimeException: Unable to pause activity

RuntimeException: Unable to pause activity 错误的解决方法:

详细正真原因不明,如果你用了ViewPager,并且Adapter是FragmentPagerAdapter的话,将FragmentPagerAdapter改成FragmentStatePagerAdapter即可暂时解决问题。

如果使用了FragmentPagerAdapter,按HOME键退出即出现如下错误:

W/dalvikvm(851): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime(851): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(851): java.lang.RuntimeException: Unable to pause activity {com.example.example/com.example.example.Main}: java.lang.NullPointerException
E/AndroidRuntime(851): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3162)
E/AndroidRuntime(851): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3119)
E/AndroidRuntime(851): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3102)
E/AndroidRuntime(851): at android.app.ActivityThread.access$2400(ActivityThread.java:119)
E/AndroidRuntime(851): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
E/AndroidRuntime(851): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(851): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(851): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(851): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(851): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(851): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(851): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(851): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(851): Caused by: java.lang.NullPointerException
E/AndroidRuntime(851): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
E/AndroidRuntime(851): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
E/AndroidRuntime(851): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
E/AndroidRuntime(851): at android.app.Activity.performSaveInstanceState(Activity.java:1022)
E/AndroidRuntime(851): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1180)
E/AndroidRuntime(851): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3144)
E/AndroidRuntime(851): ... 12 more
I/dalvikvm(851): threadid=7: reacting to signal 3
I/dalvikvm(851): Wrote stack trace to '/data/anr/traces.txt'

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

w

Connecting to %s