Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:com.example.android.common.play.PlayHelper.java

/**
 * Checks for Google Play Services installation on the device. If found, validates the
 * installed version against the requested version. If the service is installed but
 * can't be used, the utility initiates a recovery with user intervention.
 *
 * @param context The context to be associated with the request. For compatibility with 1.6+,
 *                subclass {@link FragmentActivity}.
 * @param requestCode If we need to download Google Play Services, the download activity will be
 *                    started using {@link Activity#startActivityForResult(Intent, int)}
 * @param versionCode The minimum required version of the library.
 * @return True, if successful./*from  ww w.  j a v  a2s  .  com*/
 */
public static boolean checkGooglePlayServiceAvailability(FragmentActivity context, int requestCode,
        int versionCode) {

    // Query for the status of Google Play services on the device
    int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

    if ((statusCode == ConnectionResult.SUCCESS)
            && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= versionCode)) {
        return true;
    } else {
        if (GooglePlayServicesUtil.isUserRecoverableError(statusCode)) {
            Dialog eDialog = GooglePlayServicesUtil.getErrorDialog(statusCode, context, requestCode);
            // If Google Play services can provide an error dialog
            if (eDialog != null) {
                // Create a new DialogFragment for the error dialog
                ErrorDialogFragment errorFragment = new ErrorDialogFragment();
                // Set the dialog in the DialogFragment
                errorFragment.setDialog(eDialog);
                // Show the error dialog in the DialogFragment
                errorFragment.show(context.getSupportFragmentManager(), "Activity Recognition");
            }
        } else {
            return false;
        }
    }
    return false;
}

From source file:org.spinsuite.adapters.FragmentTabsAdapter.java

/**
 * /*www.ja va2 s .  c o m*/
 * *** Constructor ***
 * @author Yamel Senih 06/02/2013, 12:49:26
 * @param fm
 * @param ctx
 */
public FragmentTabsAdapter(FragmentActivity activity, TabHost mTabHost, Cust_ViewPager pager) {
    super(activity.getSupportFragmentManager());
    this.fm = activity.getSupportFragmentManager();
    mContext = activity;
    this.mTabHost = mTabHost;
    pager.setAdapter(this);
}

From source file:com.pytacular.checkitcloudchecklist.TabListener.java

public TabListener(FragmentActivity activity, String tag, Class fragmentClass) {
    mActivity = activity;/*from  w w w .j  a v  a 2  s . c om*/
    mTag = tag;
    mFragmentClass = fragmentClass;
    mFragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
}

From source file:com.github.mobile.ui.fragments.TabsAdapter.java

public TabsAdapter(final FragmentActivity activity, final TabHost tabHost, final ViewPager pager) {
    super(activity.getSupportFragmentManager());
    mContext = activity;//from  ww  w  .j a  v a2s . c  o  m
    mTabHost = tabHost;
    mViewPager = pager;
    mTabHost.setOnTabChangedListener(this);
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
}

From source file:com.zepan.android.widget.SwitchPageView.java

/**
 * @param context//w ww. j a v  a 2  s .  c  om
 * @param attrs
 */
public SwitchPageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    FragmentActivity ac = (FragmentActivity) context;
    frmMgr = ac.getSupportFragmentManager();
}

From source file:br.com.bioscada.apps.biotracks.TabsAdapter.java

public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager viewPager) {
    super(activity.getSupportFragmentManager());
    this.context = activity;
    this.tabHost = tabHost;
    this.viewPager = viewPager;
    this.tabHost.setOnTabChangedListener(this);
    this.viewPager.setAdapter(this);
    this.viewPager.setOnPageChangeListener(this);
}

From source file:org.onepf.opfiab.ActivityIabHelperImpl.java

ActivityIabHelperImpl(@Nullable final FragmentActivity fragmentActivity, @Nullable final Activity activity) {
    super(fragmentActivity == null ? null : fragmentActivity.getSupportFragmentManager(),
            activity == null ? null : activity.getFragmentManager());
    this.activity = activity;
    this.fragmentActivity = fragmentActivity;
}

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingPagerAdapter.java

private MeetingPagerAdapter(FragmentActivity activity, int teamId, MeetingCursorWrapper cursor) {
    super(activity.getSupportFragmentManager());
    Log.v(TAG, "Constructor");
    mContext = activity;//from  w  ww  .ja  v a 2  s .c  om
    mTeamId = teamId;
    mMeetingObserver = new MeetingObserver(new Handler(Looper.getMainLooper()));
    mCursor = cursor;
    mCursor.registerContentObserver(mMeetingObserver);
}

From source file:org.coursera.android.shift.ShiftLauncherView.java

private void addFragment(FragmentActivity activity, Fragment fragment, String tag, boolean isVisible) {
    FragmentManager manager = activity.getSupportFragmentManager();
    Fragment oldInstance = manager.findFragmentByTag(tag);
    if (oldInstance == null) {
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(android.R.id.content, fragment, tag);
        if (!isVisible) {
            transaction.hide(fragment);/*from w  w  w  .j a v  a 2  s. c om*/
        } else if (tag.equals(TABS_TAG)) {
            manager.popBackStack(TABS_BACK_STACK, FragmentManager.POP_BACK_STACK_INCLUSIVE);
            transaction.addToBackStack(TABS_BACK_STACK);
        }
        transaction.commit();
    }
}

From source file:anrana.ucsd.async.ManagedAsyncTask.java

public ManagedAsyncTask(FragmentActivity activity, String fragmentTag) {

    FragmentManager fragmentManager = activity.getSupportFragmentManager();

    mManager = (TaskManagerFragment) fragmentManager.findFragmentByTag(fragmentTag);

    if (mManager == null) {
        mManager = new TaskManagerFragment();

        fragmentManager.beginTransaction().add(mManager, fragmentTag).commit();
    }//from   w w  w  . j  av a 2 s.  c om

    mTask = new InternalAsyncTask();
}