Skip to content Skip to sidebar Skip to footer

Fragment Null Must Be A Public Static Class To Be Properly Recreated From Instance State

I am not able to figure out why my app crashes when getSupportFragmentManager() is called.I have used similar code in other apps to create alert dialogs without any issues.please h

Solution 1:

Your DialogFragment is an anonymous class, and in Java anonymous classes can only be instantiated by parent classes: the new DialogFragment() is in fact this.new DialogFragment(). Apparently, when FragmentManager tries to recreate your DialogFragment upon a configuration change, it can't, since it doesn't have the access to the instance of the parent class. The solution would be to either declare a static subclass of DialogFragment, or to declare a top-level subclass of DialogFragment, and use it instead of the anonymous class.

Solution 2:

I know you have done this step but just asking did you tried to rebuild your APK?because if this code works in other applications then their must be some .classes issue.

Solution 3:

check which type of Fragment you have in your imports whether your'e using android.support.v4.app.Fragment or android.os.Fragment.

Post a Comment for "Fragment Null Must Be A Public Static Class To Be Properly Recreated From Instance State"