List of usage examples for android.app Fragment getActivity
final public Activity getActivity()
From source file:com.github.piasy.safelyandroid.activity.StartActivityDelegate.java
/** * start activity from {@link android.app.Fragment} * * @param fragment fragment we start from * @param intent intent to start/* w w w .j a v a 2 s . co m*/ * @param options options used to start activity * @return {@code true} if we start it safely, {@code false} if it's unsafe so we didn't start * it */ public static boolean startActivitySafely(@NonNull android.app.Fragment fragment, @NonNull Intent intent, Bundle options) { if (isIntentSafe(fragment.getActivity().getPackageManager(), intent)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { fragment.startActivity(intent, options); } else { fragment.startActivity(intent); } return true; } return false; }
From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java
public static void actionDisplayError(Fragment f, Exception e) { Intent i = new Intent(PrivateIntent.ACTION_DISPLAY_ERROR); if (e != null) { i.putExtra(PrivateIntent.EXTRA_ERROR_DATA, e); }//w w w .ja v a 2s .c o m LocalBroadcastManager.getInstance(f.getActivity()).sendBroadcast(i); }
From source file:com.github.piasy.safelyandroid.activity.StartActivityDelegate.java
/** * start activity for result from {@link android.app.Fragment} * * @param fragment fragment we start from * @param intent intent to start/*from ww w .java2 s. c om*/ * @param requestCode request code * @param options options used to start activity * @return {@code true} if we start it safely, {@code false} if it's unsafe so we didn't start * it */ public static boolean startActivityForResultSafely(@NonNull android.app.Fragment fragment, @NonNull Intent intent, int requestCode, Bundle options) { if (isIntentSafe(fragment.getActivity().getPackageManager(), intent)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { fragment.startActivityForResult(intent, requestCode, options); } else { fragment.startActivityForResult(intent, requestCode); } return true; } return false; }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static void launchWifiSetup(Fragment fragment) { final Context context = fragment.getActivity(); CMAccountUtils.tryEnablingWifi(context); Intent intent = getWifiSetupIntent(context); fragment.startActivityForResult(intent, CMAccount.REQUEST_CODE_SETUP_WIFI); }
From source file:com.github.dpsm.android.auth.GoogleOauthTokenObservable.java
/** * Creates an instance of a GoogleOauthTokenObservable bound to the specified Fragment's * Activity context to emit access tokens for the specified account. * * @param fragment the Fragment from which Activity context to use to interact with the * Android system./*ww w . j av a 2 s .c om*/ * @param accountName the target Google account name. * @param scope OAuth token scope. * @return an instance of the Observable. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static GoogleOauthTokenObservable create(final Fragment fragment, final String accountName, final String scope) { if (fragment == null) { throw new IllegalArgumentException("Fragment can not be null!"); } return create(fragment.getActivity(), accountName, scope); }
From source file:com.phonemetra.account.util.AccountUtils.java
public static void launchWifiSetup(Fragment fragment) { final Context context = fragment.getActivity(); AccountUtils.tryEnablingWifi(context); Intent intent = getWifiSetupIntent(context); fragment.startActivityForResult(intent, Account.REQUEST_CODE_SETUP_WIFI); }
From source file:com.google.zxing.integration.android.CustomerIntentIntegrator.java
/** * @param fragment {@link Fragment} invoking the integration. * {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead * of an {@link Activity} *///ww w . java2s . co m @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static CustomerIntentIntegrator forFragment(Fragment fragment) { CustomerIntentIntegrator integrator = new CustomerIntentIntegrator(fragment.getActivity()); integrator.fragment = fragment; return integrator; }
From source file:com.github.dpsm.android.auth.GoogleOauthTokenObservable.java
/** * Creates an instance of a GoogleOauthTokenObservable bound to the specified Fragment's * Activity context to emit access tokens for the specified account. * * @param fragment the Fragment from which Activity context to use to interact with the * Android system./*from ww w .j a va 2 s . c o m*/ * @param accountName the target Google account name. * @param scope OAuth token scope. * @return an instance of the Observable. */ public static GoogleOauthTokenObservable create(final android.support.v4.app.Fragment fragment, final String accountName, final String scope) { if (fragment == null) { throw new IllegalArgumentException("Fragment can not be null!"); } return create(fragment.getActivity(), accountName, scope); }
From source file:org.wdd.app.android.catgirl.permission.PermissionManager.java
/** * Get default setting dialog.//from w ww. ja va 2 s . c om * * @param fragment {@link android.app.Fragment}. * @return {@link SettingDialog}. */ public static @NonNull SettingDialog defaultSettingDialog(@NonNull android.app.Fragment fragment) { return new SettingDialog(fragment.getActivity(), new SettingExecutor(fragment)); }
From source file:com.google.zxing.integration.android.CustomerIntentIntegrator.java
/** * @param fragment {@link Fragment} invoking the integration. * {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead * of an {@link Activity} */// w w w. j a va2s. c o m public static CustomerIntentIntegrator forSupportFragment(android.support.v4.app.Fragment fragment) { CustomerIntentIntegrator integrator = new CustomerIntentIntegrator(fragment.getActivity()); integrator.supportFragment = fragment; return integrator; }