return Back Stack Immediate - Android User Interface

Android examples for User Interface:Fragment

Description

return Back Stack Immediate

Demo Code


//package com.java2s;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import java.util.List;

public class Main {
    public static boolean returnBackStackImmediate(FragmentManager fm) {
        if (fm.getBackStackEntryCount() > 0) {
            List<Fragment> fragments = fm.getFragments();

            if (fragments != null && fragments.size() > 0) {
                for (Fragment fragment : fragments) {
                    boolean hasBackStackEntry = fragment != null
                            && returnBackStackImmediate(fragment
                                    .getChildFragmentManager());

                    if (hasBackStackEntry) {
                        return true;
                    }/*from www.j a v a 2  s.c o m*/
                }
            }

            fm.popBackStackImmediate();

            return true;
        }

        return false;
    }
}

Related Tutorials