本文整理匯總了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());
}