在新开发的项目中,第一次启动MainActivity时,程序能正常运行,退出应用再次启动时程序崩溃,(反复启动、退出应用时,偶尔程序崩溃)报错如下:
AndroidRuntime: FATAL EXCEPTION: main Process: com.dell, PID: 16
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uniwill.dell.mengxi/com.dell.MainActivity}: java.lang.IllegalStateException: Activity has been destroyedat com.uniwill.dell.mengxi.fragment.FragmentController.hideFragments(FragmentController.java:74)
at com.uniwill.dell.mengxi.fragment.FragmentController.showFragment(FragmentController.java:58)
代码中使用FragmentController类管理Fragment时的切换,在FragmentController中没有重置为null,导致程序再次启动时就会报runtimeErro