package android.support.v4.app;

/**
 * Reads package private information about the {@link FragmentManager} backstack
 *
 * Thanks Hannes ;)
 */
public class BackstackReader {

    /**
     * Checks whether or not a given fragment is on the backstack of the fragment manager (could
     * also be on top of the backstack and hence visible)
     *
     * @param fragment The fragment you want to check if its on the back stack
     * @return true, if the given Fragment is on the back stack, otherwise false (not on the back
     * stack)
     */
    public static boolean isInBackStack(final Fragment fragment) {
        return fragment.isInBackStack();
    }
}

@@ -26,16 +26,74 @@
 4.app;%0A%0A
+import java.io.PrintWriter;%0Aimport java.io.StringWriter;%0A%0A
 /**%0A * R
@@ -664,16 +664,34 @@
 ment) %7B%0A
+        try %7B%0A    
         
@@ -723,16 +723,524 @@
 tack();%0A
+        %7D catch (IllegalAccessError e) %7B%0A            return isInBackStackAndroidX(fragment);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Hacky workaround because Fragment#isInBackStack is inaccessible with AndroidX%0A     */%0A    private static boolean isInBackStackAndroidX(final Fragment fragment) %7B%0A        final StringWriter writer = new StringWriter();%0A        fragment.dump(%22%22, null, new PrintWriter(writer), null);%0A        final String dump = writer.toString();%0A        return !dump.contains(%22mBackStackNesting=0%22);%0A
     %7D%0A%7D%0A

Allow usage with AndroidX