Fragment must be a public static class to be properly recreated from instance state.

最近在调试一个老库时,遇到一个崩溃:

     Caused by: java.lang.IllegalStateException: Fragment com.lianjia.common.ui.gallery.ui.PermissionNotGrantedFragment must be a public static class to be  properly recreated from instance state.
        at android.app.BackStackRecord.doAddOp(BackStackRecord.java:435)
        at android.app.BackStackRecord.add(BackStackRecord.java:415)
        at android.app.DialogFragment.show(DialogFragment.java:229)
        at com.lianjia.common.ui.gallery.ui.TransparentActivity.onCreate(TransparentActivity.java:25)
        at android.app.Activity.performCreate(Activity.java:7383)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411) 
        at android.app.ActivityThread.-wrap12(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994) 
        at android.os.Handler.dispatchMessage(Handler.java:108) 
        at android.os.Looper.loop(Looper.java:166) 
        at android.app.ActivityThread.main(ActivityThread.java:7529) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 

查看代码出处:

@SuppressLint("ValidFragment")
class PermissionNotGrantedFragment extends DialogFragment {
}

类前添加上public关键字,崩溃得以解决。

你可能感兴趣的:(Android)