使用FragmentStatePagerAdapter时会出现致命异常

时间:2016-10-14 08:55:13

标签: android android-viewpager fragmentstatepageradapter

在我10-14 12:12:55.038: A/art(17135): sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception 'android.content.pm.PackageManager$NameNotFoundException' thrown in unknown throw location com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 10-14 12:12:55.198: A/art(17135): sart/runtime/runtime.cc:292] Pending exception android.content.pm.PackageManager$NameNotFoundException thrown by 'unknown throw location' 0-14 12:12:55.198: A/art(17135): sart/runtime/runtime.cc:292] android.content.pm.PackageManager$NameNotFoundException: com.example.u29692.helloandroidjni 10-14 12:12:55.198: A/art(17135): sart/runtime/runtime.cc:292] at android.content.pm.PackageInfo android.app.ApplicationPackageManager.getPackageInfo(java.lang.String, int) (ApplicationPackageManager.java:167) 10-14 12:12:55.198: A/art(17135): sart/runtime/runtime.cc:292] at java.lang.String 的应用中,有三个带分页器效果的标签。我正在使用Activity并在应用程序被推送到后台15分钟后从后台打开应用程序时出现异常。

堆栈跟踪

FragmentStatePagerAdapter

PagerAdapter

FATAL EXCEPTION: main
Process: com.myapp, PID: 21506
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.willage/com.myapp.DashboardActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.Fragment android.support.v4.app.FragmentManager.getFragment(android.os.Bundle, java.lang.String)' on a null object reference
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
   at android.app.ActivityThread.-wrap11(ActivityThread.java)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5417)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.Fragment android.support.v4.app.FragmentManager.getFragment(android.os.Bundle, java.lang.String)' on a null object reference
   at android.support.v4.app.FragmentStatePagerAdapter.restoreState(FragmentStatePagerAdapter.java:212)
   at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1390)
   at android.view.View.dispatchRestoreInstanceState(View.java:14746)
   at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3121)
   at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3127)
   at android.view.View.restoreHierarchyState(View.java:14724)
   at android.support.v4.app.Fragment.restoreViewState(Fragment.java:465)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1094)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
   at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
   at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
   at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:598)
   at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
   at android.app.Activity.performStart(Activity.java:6253)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:148) 
   at android.app.ActivityThread.main(ActivityThread.java:5417) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

0 个答案:

没有答案