Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; public class Main { public static void removeDialogFragment(final String tag, final FragmentManager fragmentManager) { if (fragmentManager == null) { return; } final FragmentTransaction ft = fragmentManager.beginTransaction(); final Fragment prev = fragmentManager.findFragmentByTag(tag); if (prev != null && prev.isAdded()) { ft.remove(prev); } ft.commitAllowingStateLoss(); } }