Skip to content Skip to sidebar Skip to footer

Java.lang.illegalstateexception: Commit Already Called

I have tried the following code, try { final Activity activity = ctx; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); android.app.Fragment pr

Solution 1:

newFragment.show(ft, "dialog")

show calls internally commit. So you probably want get rid of

ft.commitAllowingStateLoss();

or you can get rid of

newFragment.show(ft, "dialog");

add call

ft.add(newFragment, "dialog");
ft.commitAllowingStateLoss();

Edit

this is what DialogFragment's show() looks like

publicintshow(FragmentTransaction transaction, String tag) {
        mDismissed = false;
        mShownByMe = true;
        transaction.add(this, tag);
        mViewDestroyed = false;
        mBackStackId = transaction.commit();
        return mBackStackId;
}

Post a Comment for "Java.lang.illegalstateexception: Commit Already Called"