Example usage for android.app Activity startActivityForResult

List of usage examples for android.app Activity startActivityForResult

Introduction

In this page you can find the example usage for android.app Activity startActivityForResult.

Prototype

public void startActivityForResult(@RequiresPermission Intent intent, int requestCode) 

Source Link

Document

Same as calling #startActivityForResult(Intent,int,Bundle) with no options.

Usage

From source file:com.raspberry.library.util.AppUtils.java

/**
 * App(?6.0)/*from  w w  w.j av a  2s.  co m*/
 *
 * @param activity    activity
 * @param file        
 * @param requestCode 
 */
public static void installApp(Activity activity, File file, int requestCode) {
    if (null == file || !file.exists())
        return;
    activity.startActivityForResult(IntentUtils.getInstallAppIntent(file), requestCode);
}

From source file:com.androidquery.simplefeed.activity.FriendsActivity.java

public static void start(Activity act, boolean selectable) {

    Intent intent = new Intent(act, FriendsActivity.class);
    intent.putExtra("selectable", selectable);
    act.startActivityForResult(intent, Constants.ACTIVITY_FRIENDS);

}

From source file:com.yanzhenjie.album.Album.java

/**
 * @param activity       ?Activity/*w  w w  . ja va2 s. c o  m*/
 * @param requestCode    ?
 * @param limitCount     
 * @param toolbarColor   Toolbar 
 * @param statusBarColor ??
 */
public static void startAlbum(Activity activity, int requestCode, int limitCount, @ColorInt int toolbarColor,
        @ColorInt int statusBarColor) {
    Intent intent = new Intent(activity, AlbumActivity.class);
    intent.putExtra(KEY_INPUT_LIMIT_COUNT, limitCount);
    intent.putExtra(KEY_INPUT_TOOLBAR_COLOR, toolbarColor);
    intent.putExtra(KEY_INPUT_STATUS_COLOR, statusBarColor);
    activity.startActivityForResult(intent, requestCode);
}

From source file:com.youshe.yangyi.common_app.util.PermissionUtils.java

/**
 * ??/*from w w w  .  j a v a  2s . com*/
 *
 * @param cxt
 * @param req
 * @return
 */
@TargetApi(23)
public static boolean checkSettingAlertPermission(Object cxt, int req) {
    if (cxt instanceof Activity) {
        Activity activity = (Activity) cxt;
        if (!Settings.canDrawOverlays(activity.getBaseContext())) {
            Log.i(TAG, "Setting not permission");

            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + activity.getPackageName()));
            activity.startActivityForResult(intent, req);
            return false;
        }
    } else if (cxt instanceof Fragment) {
        Fragment fragment = (Fragment) cxt;
        if (!Settings.canDrawOverlays(fragment.getActivity())) {
            Log.i(TAG, "Setting not permission");

            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + fragment.getActivity().getPackageName()));
            fragment.startActivityForResult(intent, req);
            return false;
        }
    } else {
        throw new RuntimeException("cxt is net a activity or fragment");
    }

    return true;
}

From source file:com.nestapi.lib.UserAuthActivity.java

static void launchAuthFlowForResult(Activity activity, int requestCode, ClientMetadata data) {
    final Intent authFlowIntent = new Intent(activity, UserAuthActivity.class);
    authFlowIntent.putExtra(CLIENT_METADATA_KEY, data);
    log("Launching auth flow Activity...");
    activity.startActivityForResult(authFlowIntent, requestCode);
}

From source file:info.guardianproject.gpg.FileDialogFragment.java

/**
 * Opens the preferred installed file manager on Android and shows a toast
 * if no manager is installed./*from   w  ww .j  a va 2 s  .  c o m*/
 * 
 * @param activity
 * @param filename default selected file, not supported by all file managers
 * @param type can be text/plain for example
 * @param requestCode requestCode used to identify the result coming back
 *            from file manager to onActivityResult() in your activity
 */
public static void openFile(Activity activity, String filename, String type, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    intent.setData(Uri.parse("file://" + filename));
    intent.setType(type);

    try {
        activity.startActivityForResult(intent, requestCode);
    } catch (ActivityNotFoundException e) {
        // No compatible file manager was found.
        Toast.makeText(activity, R.string.error_no_file_manager_installed, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.hengtiansoft.ecommerce.library.base.util.PermissionUtils.java

/**
 * ??//from w w w. ja  v  a 2s.  c  om
 *
 * @param cxt
 * @param req
 * @return
 */
@TargetApi(23)
public static boolean checkSettingAlertPermission(Object cxt, int req) {
    if (cxt instanceof Activity) {
        Activity activity = (Activity) cxt;
        if (!Settings.canDrawOverlays(activity.getBaseContext())) {
            LogUtil.i("Setting not permission");

            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + activity.getPackageName()));
            activity.startActivityForResult(intent, req);
            return false;
        }
    } else if (cxt instanceof Fragment) {
        Fragment fragment = (Fragment) cxt;
        if (!Settings.canDrawOverlays(fragment.getActivity())) {
            LogUtil.i("Setting not permission");

            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + fragment.getActivity().getPackageName()));
            fragment.startActivityForResult(intent, req);
            return false;
        }
    } else {
        throw new RuntimeException("cxt is net a activity or fragment");
    }

    return true;
}

From source file:com.brq.wallet.activity.export.DecryptBip38PrivateKeyActivity.java

public static void callMe(Activity currentActivity, String encryptedPrivateKey, int requestCode) {
    Intent intent = new Intent(currentActivity, DecryptBip38PrivateKeyActivity.class);
    intent.putExtra("encryptedPrivateKey", encryptedPrivateKey);
    currentActivity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static Uri launchActivityForResult(Activity activity, Intent intent, int requestCode) {
    SimpleDateFormat timeStampFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
    String filename = timeStampFormat.format(new Date());
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, filename);
    Uri photoUri = activity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
    activity.startActivityForResult(intent, requestCode);
    return photoUri;
}

From source file:io.hypertrack.sendeta.util.images.EasyImage.java

public static void openChooser(Activity activity, String chooserTitle) {
    try {/*from w ww  .j  a  v a 2  s .  com*/
        Intent intent = createChooserIntent(activity, chooserTitle);
        activity.startActivityForResult(intent, REQ_SOURCE_CHOOSER);
    } catch (IOException e) {
        e.printStackTrace();
    }
}