本文整理汇总了Java中android.support.v4.app.Fragment.startActivityForResult方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.startActivityForResult方法的具体用法?Java Fragment.startActivityForResult怎么用?Java Fragment.startActivityForResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.startActivityForResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchForResult
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void launchForResult(Fragment fragment, ArrayList<BeautyPhotoInfo> datas, int index) {
Intent intent = new Intent(fragment.getContext(), BigPhotoActivity.class);
intent.putParcelableArrayListExtra(BIG_PHOTO_KEY, datas);
intent.putExtra(PHOTO_INDEX_KEY, index);
intent.putExtra(FROM_LOVE_ACTIVITY, true);
fragment.startActivityForResult(intent, CommonConstant.REQUEST_CODE);
fragment.getActivity().overridePendingTransition(R.anim.expand_vertical_entry, R.anim.hold);
}
示例2: go
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void go(Fragment fragment) {
FragmentActivity activity = fragment.getActivity();
Context context = fragment.getContext();
Intent intent = getIntent(activity != null ? activity : context);
if (intent == null) {
return;
}
Bundle options = mRouteRequest.getActivityOptionsCompat() == null ?
null : mRouteRequest.getActivityOptionsCompat().toBundle();
if (mRouteRequest.getRequestCode() < 0) {
fragment.startActivity(intent, options);
} else {
fragment.startActivityForResult(intent, mRouteRequest.getRequestCode(), options);
}
if (activity != null && mRouteRequest.getEnterAnim() != 0 && mRouteRequest.getExitAnim() != 0) {
// Add transition animation.
activity.overridePendingTransition(
mRouteRequest.getEnterAnim(), mRouteRequest.getExitAnim());
}
callback(RouteResult.SUCCEED, null);
}
示例3: retrieveInputFromUser
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void retrieveInputFromUser(Fragment fragment) {
ensurePermission(fragment);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
fragment.getString(R.string.speech_prompt));
try {
fragment.startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {
setFailureMessage(fragment.getString(R.string.speech_not_supported));
}
}
示例4: forResult
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* Start to select media and wait for result.
*
* @param requestCode Identity of the request Activity or Fragment.
*/
public void forResult(int requestCode) {
Activity activity = mMatisse.getActivity();
if (activity == null) {
return;
}
Intent intent = new Intent(activity, MatisseActivity.class);
Fragment fragment = mMatisse.getFragment();
if (fragment != null) {
fragment.startActivityForResult(intent, requestCode);
} else {
activity.startActivityForResult(intent, requestCode);
}
}
示例5: startActivityForResult
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void startActivityForResult(Activity activity, Fragment fragment, final Intent intent, final int reqCodeCamera) throws ActivityNotFoundException {
if (fragment == null) {
activity.startActivityForResult(intent, reqCodeCamera);
} else {
fragment.startActivityForResult(intent, reqCodeCamera);
}
}
示例6: openChooser
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void openChooser(Fragment fragment, String chooserTitle) {
try {
Intent intent = createChooserIntent(fragment.getActivity(), chooserTitle);
fragment.startActivityForResult(intent, REQ_SOURCE_CHOOSER);
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: openAlbums
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 通过打开相册
*/
public void openAlbums(Fragment fragment, int currentSelectPhotoMaxCount) {
if (fragment == null) {
return;
}
Context context = fragment.getContext();
PhotoPickerIntent pickIntent = new PhotoPickerIntent(context);
pickIntent.setSelectModel(SelectModel.MULTI);
pickIntent.setShowCarema(true); // 是否显示拍照
pickIntent.setMaxTotal(currentSelectPhotoMaxCount); // 最多选择照片数量
fragment.startActivityForResult(pickIntent, mRequestCode);
}
示例8: startChooseSpeciesActivity
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void startChooseSpeciesActivity(FragmentActivity activity, Fragment fragment,
int category, ArrayList<Species> species, boolean showOther) {
Intent intent = new Intent(activity, ChooseSpeciesActivity.class);
intent.putExtra(ChooseSpeciesActivity.EXTRA_SPECIES_CATEGORY, category);
intent.putExtra(ChooseSpeciesActivity.EXTRA_SPECIES_LIST, species);
intent.putExtra(ChooseSpeciesActivity.EXTRA_SHOW_OTHER, showOther);
if (fragment != null) {
fragment.startActivityForResult(intent, ChooseSpeciesActivity.SPECIES_REQUEST_CODE);
} else {
activity.startActivityForResult(intent, ChooseSpeciesActivity.SPECIES_REQUEST_CODE);
}
}
示例9: openAlbums
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 打开图库
*/
public static void openAlbums(Fragment context) {
//打开系统图库程序
Intent intentGallery = new Intent();
intentGallery.setType("image/*");
intentGallery.setAction(Intent.ACTION_PICK);
context.startActivityForResult(intentGallery, REQUEST_CODE_GALLERY);
}
示例10: cropImage
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void cropImage(Fragment fragment, Uri srcUri) {
cropImageUri = createImagePathUri(fragment.getContext());
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(srcUri, "image/*");
intent.putExtra("crop", "true");
////////////////////////////////////////////////////////////////
// 1.宽高和比例都不设置时,裁剪框可以自行调整(比例和大小都可以随意调整)
////////////////////////////////////////////////////////////////
// 2.只设置裁剪框宽高比(aspect)后,裁剪框比例固定不可调整,只能调整大小
////////////////////////////////////////////////////////////////
// 3.裁剪后生成图片宽高(output)的设置和裁剪框无关,只决定最终生成图片大小
////////////////////////////////////////////////////////////////
// 4.裁剪框宽高比例(aspect)可以和裁剪后生成图片比例(output)不同,此时,
// 会以裁剪框的宽为准,按照裁剪宽高比例生成一个图片,该图和框选部分可能不同,
// 不同的情况可能是截取框选的一部分,也可能超出框选部分,向下延伸补足
////////////////////////////////////////////////////////////////
// aspectX aspectY 是裁剪框宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
// outputX outputY 是裁剪后生成图片的宽高
intent.putExtra("outputX", 300);
intent.putExtra("outputY", 300);
// return-data为true时,会直接返回bitmap数据,但是大图裁剪时会出现问题,推荐下面为false时的方式
// return-data为false时,不会返回bitmap,但需要指定一个MediaStore.EXTRA_OUTPUT保存图片uri
intent.putExtra(MediaStore.EXTRA_OUTPUT, cropImageUri);
intent.putExtra("return-data", true);
fragment.startActivityForResult(intent, CROP_IMAGE);
}
示例11: startFriendsSelection
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void startFriendsSelection(@NonNull Fragment fragment, int requestCode) {
int aid = Settings.get()
.accounts()
.getCurrent();
Place place = PlaceFactory.getFriendsFollowersPlace(aid, aid, FriendsTabsFragment.TAB_ALL_FRIENDS, null);
SelectProfileCriteria criteria = new SelectProfileCriteria().setFriendsOnly(true);
Intent intent = new Intent(fragment.getActivity(), SelectProfilesActivity.class);
intent.setAction(SelectProfilesActivity.ACTION_OPEN_PLACE);
intent.putExtra(Extra.PLACE, place);
intent.putExtra(Extra.CRITERIA, criteria);
fragment.startActivityForResult(intent, requestCode);
}
示例12: launchForResult
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void launchForResult(Fragment fragment, VideoInfo data) {
Intent intent = new Intent(fragment.getContext(), VideoPlayerActivity.class);
intent.putExtra(VIDEO_DATA_KEY, data);
fragment.startActivityForResult(intent, CommonConstant.VIDEO_REQUEST_CODE);
fragment.getActivity().overridePendingTransition(R.anim.slide_bottom_entry, R.anim.hold);
}
示例13: start
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* same as {@link Fragment#startActivityForResult(Intent, int, Bundle)}
*/
public void start(@NonNull Fragment fragment, int requestCode) {
fragment.startActivityForResult(mIntent, requestCode);
}
示例14: startImagePicker
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void startImagePicker(Fragment fragment) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(MimeType.IMAGE_MIME);
fragment.startActivityForResult(Intent.createChooser(intent, fragment.getString(R.string.dlg_choose_image_from)), GALLERY_REQUEST_CODE);
}
示例15: forResult
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* Start to select media and wait for result.
*
* @param requestCode Identity of the request Activity or Fragment.
*/
public void forResult(int requestCode) {
Activity activity = vanGogh.getActivity();
if (activity == null) {
return;
}
if (cropEnable) {
vanConfig.countable = false;
vanConfig.maxCount = 1;
} else {
vanConfig.countable = countable;
vanConfig.maxCount = maxCount;
}
if (mVanMediaFilters != null && mVanMediaFilters.size() > 0) {
vanConfig.vanMediaFilters = mVanMediaFilters;
}
vanConfig.vanMediaTypeSet = mVanMediaType;
vanConfig.themeID = themeID;
vanConfig.orientation = mOrientation;
vanConfig.cameraVisible = cameraVisible;
vanConfig.packageName = packageName;
vanConfig.spanCount = rowCount;
vanConfig.cropEnable = cropEnable;
vanConfig.cropWidth = cropWidth;
vanConfig.cropHeight = cropHeight;
vanConfig.cropType = cropType;
vanConfig.thumbnailScale = thumbnailScale;
vanConfig.imageLoader = imageLoader;
vanConfig.toastListener = toastListener;
Intent intent = new Intent(activity, VanMediaActivity.class);
Fragment fragment = vanGogh.getFragment();
if (fragment != null) {
fragment.startActivityForResult(intent, requestCode);
} else {
activity.startActivityForResult(intent, requestCode);
}
}