Java Code Examples for androidx.fragment.app.FragmentActivity#startActivityForResult()

The following examples show how to use androidx.fragment.app.FragmentActivity#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: Utilities.java    From call_manage with MIT License 6 votes vote down vote up
/**
 * Check if koler is set as the default dialer app
 *
 * @param activity
 * @return boolean
 */
public static boolean checkDefaultDialer(FragmentActivity activity) {
    String packageName = activity.getApplication().getPackageName();
    try {
        if (!activity.getSystemService(TelecomManager.class).getDefaultDialerPackage().equals(packageName)) {
            // Prompt the user with a dialog to select this app to be the default phone app
            Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)
                    .putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName);
            activity.startActivityForResult(intent, DEFAULT_DIALER_RC);
            return false;
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 2
Source File: SAFUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * requestCodeに対応するUriへのアクセス要求を行う
 * @param activity
 * @param requestCode
 * @return 既にrequestCodeに対応するUriが存在していればそれを返す, 存在していなければパーミッション要求をしてnullを返す
 * @throws UnsupportedOperationException
 */
@Nullable
public static Uri requestPermission(
	@NonNull final FragmentActivity activity,
	final int requestCode) {

	if (BuildCheck.isLollipop()) {
		final Uri uri = getStorageUri(activity, requestCode);
		if (uri == null) {
			// requestCodeに対応するUriへのパーミッションを保持していない時は要求してnullを返す
			activity.startActivityForResult(prepareStorageAccessPermission(), requestCode);
		}
		return uri;
	} else {
		throw new UnsupportedOperationException("should be API>=21");
	}
}
 
Example 3
Source File: SAFUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * requestCodeに対応するUriへのアクセス要求を行う
 * @param activity
 * @param requestCode
 * @return 既にrequestCodeに対応するUriが存在していればそれを返す, 存在していなければパーミッション要求をしてnullを返す
 * @throws UnsupportedOperationException
 */
@Nullable
public static Uri requestPermission(
	@NonNull final FragmentActivity activity,
	final int requestCode) {

	if (BuildCheck.isLollipop()) {
		final Uri uri = getStorageUri(activity, requestCode);
		if (uri == null) {
			// requestCodeに対応するUriへのパーミッションを保持していない時は要求してnullを返す
			activity.startActivityForResult(prepareStorageAccessPermission(), requestCode);
		}
		return uri;
	} else {
		throw new UnsupportedOperationException("should be API>=21");
	}
}
 
Example 4
Source File: SAFSingleFileUtils.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * ファイル読み込み用のUriを要求
 * KITKAT以降で個別のファイル毎にパーミッション要求する場合
 * @param activity
 * @param mime
 * @param requestCode
 */
public static void requestOpenDocument(
	@NonNull final FragmentActivity activity,
	final String mime, final int requestCode) {

	if (BuildCheck.isKitKat()) {
		activity.startActivityForResult(prepareOpenDocumentIntent(mime), requestCode);
	}
}
 
Example 5
Source File: SAFSingleFileUtils.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * ファイル保存用のUriを要求
 * KITKAT以降で個別のファイル毎にパーミッション要求する場合
 * @param activity
 * @param mime
 * @param requestCode
 */
public static void requestCreateDocument(
	@NonNull final FragmentActivity activity,
	final String mime, final int requestCode) {

	if (BuildCheck.isKitKat()) {
		activity.startActivityForResult(prepareCreateDocument(mime, null), requestCode);
	}
}
 
Example 6
Source File: SAFSingleFileUtils.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * ファイル保存用のUriを要求
 * KITKAT以降で個別のファイル毎にパーミッション要求する場合
 * @param activity
 * @param mime
 * @param defaultName
 * @param requestCode
 */
public static void requestCreateDocument(
	@NonNull final FragmentActivity activity,
	final String mime, final String defaultName, final int requestCode) {

	if (BuildCheck.isKitKat()) {
		activity.startActivityForResult(prepareCreateDocument(mime, defaultName), requestCode);
	}
}
 
Example 7
Source File: VideoTrimmerActivity.java    From Android-Video-Trimmer with Apache License 2.0 5 votes vote down vote up
public static void call(FragmentActivity from, String videoPath) {
  if (!TextUtils.isEmpty(videoPath)) {
    Bundle bundle = new Bundle();
    bundle.putString(VIDEO_PATH_KEY, videoPath);
    Intent intent = new Intent(from, VideoTrimmerActivity.class);
    intent.putExtras(bundle);
    from.startActivityForResult(intent, VIDEO_TRIM_REQUEST_CODE);
  }
}