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

The following examples show how to use android.support.v4.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: ActSelectTypeActivity.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public static void gotoSelectActApplyItemForResult(Fragment fragment, JoinField joinField, int reqeustCode) {
    if (joinField == null) {
        return;
    }
    Intent intent = new Intent(fragment.getActivity(), ActSelectTypeActivity.class);
    intent.putExtra("joinField", joinField);
    if ("select".equals(joinField.getFormType()) || "radio".equals(joinField.getFormType())) {
        intent.putExtra("type", 2);
    } else if ("list".equals(joinField.getFormType()) || "checkbox".equals(joinField.getFormType())) {
        intent.putExtra("type", 3);
    } else {
        return;
    }
    fragment.startActivityForResult(intent, reqeustCode);


}
 
Example 2
Source File: SelectionCreator.java    From Matisse with Apache License 2.0 6 votes vote down vote up
/**
 * Start to select media and wait for result.
 * @param requestCode Identity of the request Activity or Fragment.
 */
public void forResult(int requestCode) {
    mSelectionSpec.requestCode = 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);
    }
}
 
Example 3
Source File: Navigator.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
private void navigateToFileManagerForResult(Fragment fragment) {
    Intent intent = new Intent();
    intent.setType(FILE_MIME_TYPE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        intent.setAction(Intent.ACTION_GET_CONTENT);
    }

    if (intent.resolveActivity(fragment.getActivity().getPackageManager()) != null) {
        fragment.startActivityForResult(intent, PICK_FILE_REQUEST_CODE);
    }
}
 
Example 4
Source File: CalculatorBuilder.java    From CalculatorInputView with Apache License 2.0 5 votes vote down vote up
/**
 * Start the activity using the parent fragment
 *
 * @param fragment the current fragment
 */
public void start(Fragment fragment) {
    Intent i = new Intent(fragment.getContext(), CalculatorActivity.class);
    if (!TextUtils.isEmpty(activityTitle)) {
        i.putExtra(CalculatorActivity.TITLE_ACTIVITY, activityTitle);
    }

    if (!TextUtils.isEmpty(value)) {
        i.putExtra(CalculatorActivity.VALUE, value);
    }

    fragment.startActivityForResult(i, CalculatorActivity.REQUEST_RESULT_SUCCESSFUL);
}
 
Example 5
Source File: Session.java    From barterli_android with Apache License 2.0 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: PicSelectorActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public static void selectPic(Fragment fragment, int remain) {
    Intent intent = new Intent();
    intent.setClass(fragment.getActivity(),PicSelectorActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt("remain", remain);
    intent.putExtras(bundle);
    ZogUtils.printError(PicSelectorActivity.class, "ImageLibRequestResultCode.REQUEST_SELECT_PIC:" + ImageLibRequestResultCode.REQUEST_SELECT_PIC);

    fragment.startActivityForResult(intent, ImageLibRequestResultCode.REQUEST_SELECT_PIC);
}
 
Example 7
Source File: UiUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static void showFileDirPicker(Fragment f, int code) {
    Intent intent = new Intent(f.getActivity(), FilePickerActivity.class);
    intent.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
    // Configure initial directory by specifying a String.
    // You could specify a String like "/storage/emulated/0/", but that can
    // dangerous. Always use Android's API calls to get paths to the SD-card or
    // internal memory.
    File dir = UiUtils.getDownloadFilePath(f.getActivity());
    String path = dir == null ? Environment.getExternalStorageDirectory().getPath() : dir.getAbsolutePath();
    intent.putExtra(FilePickerActivity.EXTRA_START_PATH, path);

    f.startActivityForResult(intent, code);
}
 
Example 8
Source File: PickerAlbumPreviewActivity.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
public static void start(Fragment fragment, List<PhotoInfo> photos, int position, boolean supportOrig,
                         boolean isOrig, List<PhotoInfo> selectPhotoList, int mutiSelectLimitSize) {
    Intent intent = PickerContract.makePreviewDataIntent(photos, selectPhotoList);
    intent.setClass(fragment.getActivity(), PickerAlbumPreviewActivity.class);
    intent.putExtra(Extras.EXTRA_PREVIEW_CURRENT_POS, position);
    intent.putExtra(Extras.EXTRA_SUPPORT_ORIGINAL, supportOrig);
    intent.putExtra(Extras.EXTRA_IS_ORIGINAL, isOrig);
    intent.putExtra(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT, mutiSelectLimitSize);
    fragment.startActivityForResult(intent, RequestCode.PICKER_IMAGE_PREVIEW);
}
 
Example 9
Source File: ActivityUtils.java    From Android-utils with Apache License 2.0 5 votes vote down vote up
public static void start(@NonNull Fragment fragment,
                         @NonNull Class<? extends Activity> activityClass,
                         int requestCode,
                         @ActivityDirection int direction) {
    fragment.startActivityForResult(new Intent(fragment.getContext(), activityClass), requestCode);
    overridePendingTransition(fragment.getActivity(), direction);
}
 
Example 10
Source File: SettingsActivity.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
public static void startWithFragment(Context context, String fragmentName, Bundle args,
                                     Fragment resultTo, int resultRequestCode, int titleResId, CharSequence title,
                                     boolean isShortcut) {
    Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResId,
            title, isShortcut);
    if (resultTo == null) {
        context.startActivity(intent);
    } else {
        resultTo.startActivityForResult(intent, resultRequestCode);
    }
}
 
Example 11
Source File: IntentUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转界面并传值
 *
 * @param fragment
 * @param cls
 * @param data
 * @param isCloseThis 是否关闭当前界面
 */
public static void gotoNextActivity(Fragment fragment, Class<?> cls,
                                    BundleData data, boolean isCloseThis, int requestFlag) {
    if (isCloseThis) {
        ((Activity) fragment.getActivity()).finish();
    }

    Intent intent = new Intent();
    pushData(intent, data);
    intent.setClass(fragment.getActivity(), cls);
    fragment.startActivityForResult(intent, requestFlag);
}
 
Example 12
Source File: Boxing.java    From boxing with Apache License 2.0 4 votes vote down vote up
/**
 * same as {@link Fragment#startActivityForResult(Intent, int, Bundle)}
 */
public void start(@NonNull Fragment fragment, int requestCode) {
    fragment.startActivityForResult(mIntent, requestCode);
}
 
Example 13
Source File: PrivateDialogActivity.java    From q-municate-android with Apache License 2.0 4 votes vote down vote up
public static void startForResult(Fragment fragment, QMUser opponent, QBChatDialog chatDialog,
                                  int requestCode) {
    Intent intent = getIntentWithExtra(fragment.getContext(), opponent, chatDialog);
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 14
Source File: AttachmentHelper.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void pickFiles(Fragment fragment) {
    fragment.startActivityForResult(pickFiles(), AttachmentHelper.REQUEST_FILES);
}
 
Example 15
Source File: MediaIntent.java    From belvedere with Apache License 2.0 4 votes vote down vote up
/**
 * Fire the intent.
 */
public void open(Fragment fragment) {
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 16
Source File: ISListActivity.java    From ImageSelector with Apache License 2.0 4 votes vote down vote up
public static void startForResult(Fragment fragment, ISListConfig config, int RequestCode) {
    Intent intent = new Intent(fragment.getActivity(), ISListActivity.class);
    intent.putExtra("config", config);
    fragment.startActivityForResult(intent, RequestCode);
}
 
Example 17
Source File: FacebookLoginActivity.java    From facebooklogin with MIT License 4 votes vote down vote up
public static void launch(Fragment fragment, String applicationId, ArrayList<String> permissions) {
    final Intent intent = new Intent(fragment.getActivity(), FacebookLoginActivity.class);
    intent.putExtra(EXTRA_FACEBOOK_APPLICATION_ID, applicationId);
    intent.putStringArrayListExtra(EXTRA_PERMISSIONS, permissions);
    fragment.startActivityForResult(intent, FacebookLoginActivity.FACEBOOK_LOGIN_REQUEST_CODE);
}
 
Example 18
Source File: GoogleHelper.java    From social-login-helper-Deprecated- with MIT License 4 votes vote down vote up
public void performSignIn(Fragment activity) {
  Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
  activity.startActivityForResult(signInIntent, RC_SIGN_IN);
}
 
Example 19
Source File: PreferenceActivity.java    From PreferenceFragment 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, int titleRes, int shortTitleRes) {
    Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes);
    if (resultTo == null) {
        startActivity(intent);
    } else {
        resultTo.startActivityForResult(intent, resultRequestCode);
    }
}
 
Example 20
Source File: SysUtil.java    From PracticeCode with Apache License 2.0 2 votes vote down vote up
/**
 * 启动图片剪裁
 *
 * @param uri          图片内容Uri
 * @param aspectX      剪裁框X比例
 * @param aspectY      剪裁框Y比例
 * @param outputX      输出尺寸X大小
 * @param outputY      输出尺寸Y大小
 * @param fragment     启动环境
 * @param requestCode  启动标识码(onActivityResult)
 */
public void cropImage(Uri uri, int aspectX, int aspectY, int outputX,
                      int outputY, int requestCode, Fragment fragment){
    fragment.startActivityForResult(
            getCropImageIntent(uri, aspectX, aspectY, outputX, outputY), requestCode);
}