this is not a duplicate question as the occurrence of the issue is different.. as i am only experiencing this behavior when i try to do exact what i have mentioned(layout order wise)
i am trying to create a new dialog fragment trough another dialog fragment. when i try to do that it throws an error
java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentManager.beginTransaction()' on a null object reference
at android.support.v4.app.DialogFragment.show(DialogFragment.java:142)
this is the related code
ForgotPasswordFailedFragment forgotPasswordFailedFragment = new ForgotPasswordFailedFragment();
forgotPasswordFailedFragment.show(getFragmentManager(), "Password Reset Failed");
so my view order is something like this..
mainActivity -> fragment -> dialogfragment -> dialogfragment (i'am trying to get this)
i have tried mentioned answers and tease are the errors that occurred for each change...
ForgotPswrdSuccessFragment forgotPswrdSuccessFragment = new ForgotPswrdSuccessFragment(); forgotPswrdSuccessFragment.show(requireActivity().getSupportFragmentManager(), "Password Reset Failed");
this throws
Fragment ForgotPasswordDFragment{725811b} not attached to an activity.
at android.support.v4.app.Fragment.requireActivity(Fragment.java:724)
at *********.SignIn.ForgotPassword.ForgotPasswordDFragment.showSuccessDialog(ForgotPasswordDFragment.java:85)
ForgotPasswordDFragment is a dialog fragment which is on a fragment and i am calling another dialogfragment from (ForgotPasswordDFragment) there..and now that action is throwing above mentioned eror
for this
forgotPswrdSuccessFragment.show(this.getChildFragmentManager(), "Password Reset Failed");
the exception is
java.lang.IllegalStateException: Fragment has not been attached yet. at android.support.v4.app.Fragment.instantiateChildFragmentManager(Fragment.java:2383)