imLibo / FilePicker

:fire::fire::fire:Android文件、图片选择器,可按文件夹查找,文件类型查找,支持自定义相机
MIT License
322 stars 68 forks source link

资源回收的时候空指针了 #31

Open Flipped199 opened 4 years ago

Flipped199 commented 4 years ago

2020-05-30 11:16:54.573 4046-4046 E/AndroidRuntime: FATAL EXCEPTION: main Process: xxx, PID: 4046 java.lang.RuntimeException: Unable to destroy activity {xxx/com.ess.filepicker.activity.SelectFileByScanActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4167) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4185) at android.app.ActivityThread.-wrap6(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at androidx.fragment.app.Fragment.performDetach(Fragment.java:2849) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1034) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659) at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644) at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329) at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366) at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233) at com.ess.filepicker.activity.SelectFileByScanActivity.onDestroy(SelectFileByScanActivity.java:122) at android.app.Activity.performDestroy(Activity.java:6864) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1153) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4154) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4185)  at android.app.ActivityThread.-wrap6(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

roomanl commented 4 years ago

我改成androidx也出现这个问题了。BaseFileFragment文件onDetach方法里面childFragmentManager.set(this, null);注释即可解决