本文整理匯總了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);
}
}