androidx.fragment.app.Fragment.startActivityForResult()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中androidx.fragment.app.Fragment.startActivityForResult()方法的一些代码示例,展示了Fragment.startActivityForResult()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.startActivityForResult()方法的具体详情如下:
包路径:androidx.fragment.app.Fragment
类名称:Fragment
方法名:startActivityForResult

Fragment.startActivityForResult介绍

暂无

代码示例

代码示例来源:origin: googlesamples/easypermissions

private void startForResult(Intent intent) {
  if (mActivityOrFragment instanceof Activity) {
    ((Activity) mActivityOrFragment).startActivityForResult(intent, mRequestCode);
  } else if (mActivityOrFragment instanceof Fragment) {
    ((Fragment) mActivityOrFragment).startActivityForResult(intent, mRequestCode);
  }
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

/**
 * Same as {@link #startPickImageActivity(Activity) startPickImageActivity} method but instead of
 * being called and returning to an Activity, this method can be called and return to a Fragment.
 *
 * @param context The Fragments context. Use getContext()
 * @param fragment The calling Fragment to start and return the image to
 */
public static void startPickImageActivity(@NonNull Context context, @NonNull Fragment fragment) {
 fragment.startActivityForResult(
   getPickImageChooserIntent(context), PICK_IMAGE_CHOOSER_REQUEST_CODE);
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

/**
 * Start {@link CropImageActivity}.
 *
 * @param fragment fragment to receive result
 */
public void start(
  @NonNull Context context, @NonNull Fragment fragment, @Nullable Class<?> cls) {
 fragment.startActivityForResult(getIntent(context, cls), CROP_IMAGE_ACTIVITY_REQUEST_CODE);
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

/**
 * Start {@link CropImageActivity}.
 *
 * @param fragment fragment to receive result
 */
public void start(@NonNull Context context, @NonNull Fragment fragment) {
 fragment.startActivityForResult(getIntent(context), CROP_IMAGE_ACTIVITY_REQUEST_CODE);
}

代码示例来源:origin: jkwiecien/EasyImage

public static void openChooserWithGallery(Fragment fragment, @Nullable String chooserTitle, int type) {
  try {
    Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, true, type);
    fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_GALLERY);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: jkwiecien/EasyImage

public static void openChooserWithDocuments(Fragment fragment, @Nullable String chooserTitle, int type) {
  try {
    Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle, type);
    fragment.startActivityForResult(intent, RequestCodes.SOURCE_CHOOSER | RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: jkwiecien/EasyImage

public static void openDocuments(Fragment fragment, int type) {
  Intent intent = createDocumentsIntent(fragment.getContext(), type);
  fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_DOCUMENTS);
}

代码示例来源:origin: jkwiecien/EasyImage

/**
 * Opens default galery or a available galleries picker if there is no default
 *
 * @param type Custom type of your choice, which will be returned with the images
 */
public static void openGallery(Fragment fragment, int type) {
  Intent intent = createGalleryIntent(fragment.getContext(), type);
  fragment.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
}

代码示例来源:origin: jkwiecien/EasyImage

public static void openCameraForImage(Fragment fragment, int type) {
  Intent intent = createCameraForImageIntent(fragment.getActivity(), type);
  fragment.startActivityForResult(intent, RequestCodes.TAKE_PICTURE);
}

代码示例来源:origin: jkwiecien/EasyImage

public static void openCameraForVideo(Fragment fragment, int type) {
  Intent intent = createCameraForVideoIntent(fragment.getActivity(), type);
  fragment.startActivityForResult(intent, RequestCodes.CAPTURE_VIDEO);
}

代码示例来源:origin: MCMrARM/revolution-irc

public void startActivityForResult(Intent intent, int requestId) {
  if (mFragment != null)
    mFragment.startActivityForResult(intent, requestId);
  else
    mActivity.startActivityForResult(intent, requestId);
}

代码示例来源:origin: jruesga/rview

public static void editChange( Fragment fragment, int legacyChangeId,
    String changeId, String revisionId, int requestCode) {
  Intent intent = new Intent(fragment.getContext(), EditorActivity.class);
  intent.putExtra(Constants.EXTRA_CHANGE_ID, changeId);
  intent.putExtra(Constants.EXTRA_LEGACY_CHANGE_ID, legacyChangeId);
  intent.putExtra(Constants.EXTRA_REVISION_ID, revisionId);
  intent.putExtra(Constants.EXTRA_HAS_PARENT, true);
  fragment.startActivityForResult(intent, requestCode);
}

代码示例来源:origin: akshay2211/PixImagePicker

@Override
  public void onWorkFinish(Boolean check) {
    Intent i = new Intent(context.getActivity(), Pix.class);
    i.putExtra(OPTIONS, options);
    context.startActivityForResult(i, options.getRequestCode());
  }
});

代码示例来源:origin: saki4510t/libcommon

/**
 * ファイル保存用のUriを要求
 * KITKAT以降で個別のファイル毎にパーミッション要求する場合
 * @param fragment
 * @param mime
 * @param requestCode
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void requestCreateDocument(@NonNull final Fragment fragment,
  final String mime, final int requestCode) {
  if (BuildCheck.isKitKat()) {
    fragment.startActivityForResult(prepareCreateDocument(mime, null), requestCode);
  }
}

代码示例来源:origin: esafirm/android-image-picker

@Override
  public void start() {
    fragment.startActivityForResult(getIntent(fragment.getActivity()), IpCons.RC_IMAGE_PICKER);
  }
}

代码示例来源:origin: jruesga/rview

public static void openDiffViewerActivity(Fragment fragment, ChangeInfo change,
    ArrayList<String> files, Map<String, FileInfo> info, String revisionId, String base, String current,
    String file, String comment, int requestCode) {
  Intent intent = getOpenDiffViewerActivityIntent(fragment.getContext(), change, files, info,
      revisionId, base, current, file, comment, requestCode);
  fragment.startActivityForResult(intent, requestCode);
}

代码示例来源:origin: esafirm/android-image-picker

@Override
public void start(int requestCode) {
  fragment.startActivityForResult(getIntent(fragment.getActivity()), requestCode);
}

代码示例来源:origin: esafirm/android-image-picker

public void start(Fragment fragment, int requestCode) {
  fragment.startActivityForResult(getIntent(fragment.getActivity()), requestCode);
}

代码示例来源:origin: esafirm/android-image-picker

void captureImage(Fragment fragment, BaseConfig config, int requestCode) {
  Context context = fragment.getActivity().getApplicationContext();
  Intent intent = getCameraModule().getCameraIntent(fragment.getActivity(), config);
  if (intent == null) {
    Toast.makeText(context, context.getString(R.string.ef_error_create_image_file), Toast.LENGTH_LONG).show();
    return;
  }
  fragment.startActivityForResult(intent, requestCode);
}

代码示例来源:origin: nguyenhoanglam/ImagePicker

@Override
public void start() {
  Intent intent = getIntent();
  int requestCode = config.getRequestCode() != 0 ? config.getRequestCode() : Config.RC_PICK_IMAGES;
  if (!config.isCameraOnly()) {
    fragment.startActivityForResult(intent, requestCode);
  } else {
    fragment.getActivity().overridePendingTransition(0, 0);
    fragment.startActivityForResult(intent, requestCode);
  }
}

相关文章