本文整理汇总了Java中android.app.Activity.getFragmentManager方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getFragmentManager方法的具体用法?Java Activity.getFragmentManager怎么用?Java Activity.getFragmentManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getFragmentManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: install
import android.app.Activity; //导入方法依赖的package包/类
/**
* Installs BackStack into your app. This must be called in {@link Activity#onCreate(Bundle)}
* @param activity
*/
public static void install(Activity activity){
//Standard retained fragment code. This creates a new fragment if the fragment couldn't be found
FragmentManager fm = activity.getFragmentManager();
RetainedFragment fragment = (RetainedFragment) fm.findFragmentByTag(RetainedFragment.TAG);
if (fragment == null){
fragment = new RetainedFragment();
fm.beginTransaction()
.add(fragment, RetainedFragment.TAG)
.commit();
activity.getApplication().registerActivityLifecycleCallbacks(fragment);
fragment.set(activity, new BackStackManager(activity));
}
backStack = new BackStack(fragment.getBackStackManager(
));
}
示例2: showEula
import android.app.Activity; //导入方法依赖的package包/类
public static void showEula(Activity activity) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag("dialog_eula");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
new EulaDialog().show(ft, "dialog_eula");
}
示例3: attachTo
import android.app.Activity; //导入方法依赖的package包/类
public static void attachTo(Activity activity, Object executionScope, boolean finishAfterDialog, Bundle argumentsForErrorDialog) {
android.app.FragmentManager fm = activity.getFragmentManager();
HoneycombManagerFragment fragment = (HoneycombManagerFragment) fm
.findFragmentByTag(TAG_ERROR_DIALOG_MANAGER);
if (fragment == null) {
fragment = new HoneycombManagerFragment();
fm.beginTransaction().add(fragment, TAG_ERROR_DIALOG_MANAGER).commit();
fm.executePendingTransactions();
}
fragment.finishAfterDialog = finishAfterDialog;
fragment.argumentsForErrorDialog = argumentsForErrorDialog;
fragment.executionScope = executionScope;
}
示例4: get
import android.app.Activity; //导入方法依赖的package包/类
public RequestManager get(Activity activity) {
if (Util.isOnBackgroundThread()) {
return get(activity.getApplicationContext());
} else {
assertNotDestroyed(activity);
android.app.FragmentManager fm = activity.getFragmentManager();
return fragmentGet(activity, fm, null /*parentHint*/);
}
}
示例5: onMessageLoaded
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onMessageLoaded() {
Activity currentActivity = CurrentActivityWatchdog.getCurrentActivity();
FragmentManager fragmentManager = currentActivity.getFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(IamDialog.TAG);
if (fragment == null) {
iamDialog.show(fragmentManager, IamDialog.TAG);
}
}
示例6: returnFromFragment
import android.app.Activity; //导入方法依赖的package包/类
public static void returnFromFragment(final Fragment fragment){
final Activity activity=fragment.getActivity();
if (activity!=null){
final FragmentManager fragmentManager=activity.getFragmentManager();
if (fragmentManager!=null) {
fragmentManager.popBackStack();
}
}
}
示例7: getRxPermissionsFragment
import android.app.Activity; //导入方法依赖的package包/类
private RxPermissionsFragment getRxPermissionsFragment(Activity activity) {
RxPermissionsFragment rxPermissionsFragment = findRxPermissionsFragment(activity);
boolean isNewInstance = rxPermissionsFragment == null;
if (isNewInstance) {
rxPermissionsFragment = new RxPermissionsFragment();
FragmentManager fragmentManager = activity.getFragmentManager();
fragmentManager
.beginTransaction()
.add(rxPermissionsFragment, TAG)
.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
}
return rxPermissionsFragment;
}
示例8: handleObserveLifecycle
import android.app.Activity; //导入方法依赖的package包/类
private void handleObserveLifecycle(Activity activity, LifecycleListener lifecycleListener) {
Log.d(TAG, "this context type is Activity");
assertNotDestroyed(activity);
android.app.FragmentManager fm = activity.getFragmentManager();
LifecycleListenerFragment fragment = getSupportRequestManagerFragment(fm);
FragmentLifecycle activityFragmentLifecycle = getActivityFragmentLifecycle(fragment);
activityFragmentLifecycle.addListener(lifecycleListener);
}
示例9: with
import android.app.Activity; //导入方法依赖的package包/类
public CarouselRequestManager with(Activity activity) {
FragmentManager fm = activity.getFragmentManager();
CarouselFragment carouselFragment = new CarouselFragment();
carouselFragment.setCarouselLifecycleListener(carouselLifecycleListener);
fm.beginTransaction().add(carouselFragment, CAROUSEL_FRAGMENT_TAG).commitAllowingStateLoss();
return new CarouselRequestManager(this);
}
示例10: attachTo
import android.app.Activity; //导入方法依赖的package包/类
public static void attachTo(Activity activity, Object executionScope, boolean finishAfterDialog, Bundle argumentsForErrorDialog) {
FragmentManager fm = activity.getFragmentManager();
HoneycombManagerFragment fragment = (HoneycombManagerFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER);
if (fragment == null) {
fragment = new HoneycombManagerFragment();
fm.beginTransaction().add(fragment, ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER).commit();
fm.executePendingTransactions();
}
fragment.finishAfterDialog = finishAfterDialog;
fragment.argumentsForErrorDialog = argumentsForErrorDialog;
fragment.executionScope = executionScope;
}
示例11: getFragmentManagerHelper
import android.app.Activity; //导入方法依赖的package包/类
/**
* Creates a new helper to work with either the FragmentManager or the legacy support
* FragmentManager transparently. Returns null if we're not attached to an Activity.
*
* DO NOT HOLD LONG-LIVED REFERENCES TO THE OBJECT RETURNED BY THIS METHOD, AS THIS WILL CAUSE
* MEMORY LEAKS.
*/
private @Nullable FragmentManagerHelper getFragmentManagerHelper() {
Activity activity = getCurrentActivity();
if (activity == null) {
return null;
}
if (activity instanceof FragmentActivity) {
return new FragmentManagerHelper(((FragmentActivity) activity).getSupportFragmentManager());
} else {
return new FragmentManagerHelper(activity.getFragmentManager());
}
}
示例12: getRxActivityResultsFragment
import android.app.Activity; //导入方法依赖的package包/类
private RxActivityResultsFragment getRxActivityResultsFragment(Activity activity) {
RxActivityResultsFragment fragment = findRxActivityResultsFragment(activity);
if (fragment == null) {
fragment = new RxActivityResultsFragment();
FragmentManager fragmentManager = activity.getFragmentManager();
fragmentManager.beginTransaction()
.add(fragment, TAG)
.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
}
return fragment;
}
示例13: showWiFiDialog
import android.app.Activity; //导入方法依赖的package包/类
public static void showWiFiDialog(Activity activity) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag("dialog_wifi");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
WiFiDialog.newInstance(isWiFiEnabled(activity)).show(ft, "dialog_wifi");
}
示例14: setup
import android.app.Activity; //导入方法依赖的package包/类
@Override public void setup(Activity activity) {
this.fragmentManager = new WeakReference<>(activity.getFragmentManager());
}
示例15: setup
import android.app.Activity; //导入方法依赖的package包/类
@Override public void setup(Activity activity) {
this.activity = new WeakReference<>(activity);
this.fragmentManager = new WeakReference<>(activity.getFragmentManager());
}