Java Code Examples for android.app.Fragment#startActivityForResult()

The following examples show how to use android.app.Fragment#startActivityForResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PuzzleActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
public static void startWithPaths(Fragment fragment, ArrayList<String> paths, String puzzleSaveDirPath, String puzzleSaveNamePrefix, int requestCode, boolean replaceCustom, @NonNull ImageEngine imageEngine) {
    if (null != toClass) {
        toClass.clear();
        toClass = null;
    }
    if (Setting.imageEngine != imageEngine) {
        Setting.imageEngine = imageEngine;
    }
    Intent intent = new Intent(fragment.getActivity(), PuzzleActivity.class);
    intent.putExtra(Key.PUZZLE_FILE_IS_PHOTO, false);
    intent.putStringArrayListExtra(Key.PUZZLE_FILES, paths);
    intent.putExtra(Key.PUZZLE_SAVE_DIR, puzzleSaveDirPath);
    intent.putExtra(Key.PUZZLE_SAVE_NAME_PREFIX, puzzleSaveNamePrefix);
    if (replaceCustom) {
        toClass = new WeakReference<Class<? extends Activity>>(fragment.getActivity().getClass());
    }
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 2
Source File: AccountAdder.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers Android's account adding dialog from a fragment.
 * @param fragment A fragment
 * @param result An intent result code
 */
public void addAccount(Fragment fragment, int result) {
    Intent addGoogleAccount = createAddGoogleAccountIntent();
    if (addGoogleAccount.resolveActivity(fragment.getActivity().getPackageManager()) != null) {
        fragment.startActivityForResult(addGoogleAccount, result);
    } else {
        onOpenAddGoogleAccountPageFailed(fragment.getActivity(), result);
    }
}
 
Example 3
Source File: SettingActivity.java    From Toutiao with Apache License 2.0 5 votes vote down vote up
public void startWithFragment(String fragmentName, Bundle args,
                              Fragment resultTo, int resultRequestCode, String title) {
    Intent intent = onBuildStartFragmentIntent(fragmentName, args, title);
    if (resultTo == null) {
        startActivity(intent);
    } else {
        resultTo.startActivityForResult(intent, resultRequestCode);
    }
}
 
Example 4
Source File: ImagePicker.java    From ImagePicker with Apache License 2.0 5 votes vote down vote up
/**
 * 发起选择图片
 *
 * @param fragment    发起的Fragment
 * @param requestCode 请求码
 */
public void start(Fragment fragment, int requestCode)
{
    checkCachePath(fragment.getContext());
    Intent intent = new Intent(fragment.getActivity(), ImageDataActivity.class);
    intent.putExtra(ImageContants.INTENT_KEY_OPTIONS, mOptions);
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 5
Source File: Session.java    From KlyphMessenger with MIT License 5 votes vote down vote up
AuthorizationRequest(final Fragment fragment) {
    startActivityDelegate = new StartActivityDelegate() {
        @Override
        public void startActivityForResult(Intent intent, int requestCode) {
            fragment.startActivityForResult(intent, requestCode);
        }

        @Override
        public Activity getActivityContext() {
            return fragment.getActivity();
        }
    };
}
 
Example 6
Source File: SettingsActivity.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void startWithFragment(String fragmentName, Bundle args,
        Fragment resultTo, int resultRequestCode, @StringRes int titleRes,
        @StringRes int shortTitleRes) {
    Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes);
    if (resultTo == null) {
        startActivityForResult(intent, REQUEST_CODE_FRAGMENT);
    } else {
        resultTo.startActivityForResult(intent, resultRequestCode);
    }
}
 
Example 7
Source File: OnboardingRequest.java    From wearmouse with Apache License 2.0 5 votes vote down vote up
/** Starts the onboarding activity for the specified tutorial from within a fragment. */
public void start(Fragment fragment) {
    fragment.startActivityForResult(
            OnboardingResources.forScreen(key)
                    .toIntent(activity)
                    .putExtra(OnboardingController.EXTRA_KEY, key),
            OnboardingController.ONBOARDING_REQUEST_CODE);
}
 
Example 8
Source File: PurchaseActivity.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
public static void showForResult(Fragment f, int requestCode) {
    final Intent intent = new Intent(f.getActivity(), PurchaseActivity.class);
    f.startActivityForResult(intent,
            requestCode);
}
 
Example 9
Source File: BluetoothManager.java    From libcommon with Apache License 2.0 4 votes vote down vote up
/**
 * 端末がBluetoothに対応しているが無効になっていれば有効にするように要求する
 * 前もってbluetoothAvailableで対応しているかどうかをチェックしておく
 * Bluetoothを有効にするように要求した時は#onActivityResultメソッドで結果を受け取る
 * 有効にできればRESULT_OK, ユーザーがキャンセルするなどして有効に出来なければRESULT_CANCELEDが返る
 * @param fragment
 * @param requestCode
 * @return true Bluetoothに対応していて既に有効になっている
 * @throws SecurityException パーミッションがなければSecurityExceptionが投げられる
 */
public static boolean requestBluetoothEnable(@NonNull final Fragment fragment, final int requestCode) throws SecurityException {
	final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
	if ((adapter != null) && !adapter.isEnabled()) {
		final Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
		fragment.startActivityForResult(intent, requestCode);
	}
	return adapter != null && adapter.isEnabled();
}
 
Example 10
Source File: FabSortActivity.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void start(Fragment fragment, int requestCode) {
    Intent intent = new Intent(fragment.getActivity(), FabSortActivity.class);
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 11
Source File: SimpleBackActivity.java    From KJFrameForAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * 跳转到SimpleBackActivity时,只能使用该方法跳转
 * 
 * @param cxt
 *            从哪个Activity跳转
 * @param code
 *            启动码
 * @param page
 *            要显示的Fragment
 * @param data
 *            传递的Bundle数据
 */
public static void postShowForResult(Fragment fragment, int code,
        SimpleBackPage page, Bundle data) {
    Intent intent = new Intent(fragment.getActivity(),
            SimpleBackActivity.class);
    intent.putExtra(CONTENT_KEY, page.getValue());
    intent.putExtra(DATA_KEY, data);
    fragment.startActivityForResult(intent, code);
}
 
Example 12
Source File: PreferenceActivity.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Start a new instance of this activity, showing only the given
 * preference fragment.  When launched in this mode, the header list
 * will be hidden and the given preference fragment will be instantiated
 * and fill the entire activity.
 *
 * @param fragmentName The name of the fragment to display.
 * @param args Optional arguments to supply to the fragment.
 * @param resultTo Option fragment that should receive the result of
 * the activity launch.
 * @param resultRequestCode If resultTo is non-null, this is the request
 * code in which to report the result.
 * @param titleRes Resource ID of string to display for the title of
 * this set of preferences.
 * @param shortTitleRes Resource ID of string to display for the short title of
 * this set of preferences.
 */
public void startWithFragment(String fragmentName, Bundle args,
        Fragment resultTo, int resultRequestCode, @StringRes int titleRes,
        @StringRes int shortTitleRes) {
    Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes);
    if (resultTo == null) {
        startActivity(intent);
    } else {
        resultTo.startActivityForResult(intent, resultRequestCode);
    }
}
 
Example 13
Source File: Crop.java    From UltimateAndroid with Apache License 2.0 2 votes vote down vote up
/**
 * Send the crop Intent!
 *
 * @param context Context
 * @param fragment Fragment that will receive result
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void start(Context context, Fragment fragment) {
    fragment.startActivityForResult(getIntent(context), REQUEST_CROP);
}
 
Example 14
Source File: GalleryActivity.java    From KrGallery with GNU General Public License v2.0 2 votes vote down vote up
/**
 * open gallery
 *
 * @param activity    parent activity
 * @param requestCode {@link Activity#onActivityResult}
 * @param config      {@link GalleryConfig}
 */
public static void openActivity(Fragment activity, int requestCode, GalleryConfig config) {
    Intent intent = new Intent(activity.getActivity(), GalleryActivity.class);
    intent.putExtra(GALLERY_CONFIG, config);
    activity.startActivityForResult(intent, requestCode);
}
 
Example 15
Source File: PhotoSelector.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Fragment调用系统相册
 *
 * @param fragment
 * @param requestCode
 */
public void requestPhotoPick(Fragment fragment, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 16
Source File: Crop.java    From CloudPan with Apache License 2.0 2 votes vote down vote up
/**
 * Send the crop Intent with a custom requestCode
 *
 * @param context Context
 * @param fragment Fragment to receive result
 * @param requestCode requestCode for result
 */
public void start(Context context, Fragment fragment, int requestCode) {
    fragment.startActivityForResult(getIntent(context), requestCode);
}
 
Example 17
Source File: Crop.java    From HaiNaBaiChuan with Apache License 2.0 2 votes vote down vote up
/**
 * Send the crop Intent with a custom request code
 *
 * @param context     Context
 * @param fragment    Fragment to receive result
 * @param requestCode requestCode for result
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void start(Context context, Fragment fragment, int requestCode) {
    fragment.startActivityForResult(getIntent(context), requestCode);
}
 
Example 18
Source File: Crop.java    From XERUNG with Apache License 2.0 2 votes vote down vote up
/**
 * Send the crop Intent with a custom request code
 *
 * @param context     Context
 * @param fragment    Fragment to receive result
 * @param requestCode requestCode for result
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void start(Context context, Fragment fragment, int requestCode) {
    fragment.startActivityForResult(getIntent(context), requestCode);
}
 
Example 19
Source File: Crop.java    From MyBlogDemo with Apache License 2.0 2 votes vote down vote up
/**
 * Send the crop Intent!
 *
 * @param context Context
 * @param fragment Fragment that will receive result
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void start(Context context, Fragment fragment) {
    fragment.startActivityForResult(getIntent(context), REQUEST_CROP);
}
 
Example 20
Source File: FileChooseActivity.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * 进入文件选择界面
 *
 * @param fragment
 * @param requestCode
 */
public static void goFileChooseActivity(Fragment fragment, int requestCode) {
    Intent intent = new Intent(fragment.getActivity(), FileChooseActivity.class);
    fragment.startActivityForResult(intent, requestCode);
}