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.enstage.wibmo.sdk.inapp.InAppInitActivity.java

public static void startInAppReadinessCheck(Activity activity) {
    Log.d(TAG, "startInAppReadinessCheck");

    String targetAppPackage = WibmoSDK.getWibmoIntentActionPackage();

    Intent intent = new Intent(targetAppPackage + ".ReadinessChecker");
    intent.addCategory(Intent.CATEGORY_DEFAULT);

    if (WibmoSDK.getWibmoAppPackage() != null) {
        intent.setPackage(WibmoSDK.getWibmoAppPackage());
    }/* ww  w.  j  a v a2s.c o m*/

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch

    activity.startActivityForResult(intent, REQUEST_CODE_IAP_READY);
}

From source file:com.eleybourn.bookcatalogue.BookEdit.java

/**
 * Load the EditBook activity based on the provided id in edit mode. Also
 * open to the provided tab./*w  ww.j ava 2s  .co  m*/
 * 
 * @param id
 *            The id of the book to edit
 * @param tab
 *            Which tab to open first
 */
public static void editBook(Activity a, long id, int tab) {
    Intent i = new Intent(a, BookEdit.class);
    i.putExtra(CatalogueDBAdapter.KEY_ROWID, id);
    i.putExtra(BookEdit.TAB, tab);
    a.startActivityForResult(i, UniqueId.ACTIVITY_EDIT_BOOK);
    return;
}

From source file:org.wahtod.wififixer.utility.LogUtil.java

public static void sendIssueReport(Activity activity, String report, File file) {
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType(activity.getString(R.string.log_mimetype));
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.email) });
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.subject));
    Uri uri = FileProvider.getUriForFile(activity, "org.wahtod.wififixer.files", file);
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(sendIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resInfoList) {
        String packageName = resolveInfo.activityInfo.packageName;
        activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }//w w w . j a  v  a2 s  .co  m
    sendIntent.putExtra(Intent.EXTRA_TEXT, LogUtil.getBuildInfo() + "\n\n" + report);
    activity.startActivityForResult(Intent.createChooser(sendIntent, activity.getString(R.string.emailintent)),
            1);
}

From source file:com.qiscus.sdk.filepicker.FilePickerBuilder.java

private void start(Activity context, int pickerType) {
    Intent intent = new Intent(context, FilePickerActivity.class);
    intent.putExtras(pickerOptionsBundle);

    context.startActivityForResult(intent,
            pickerType == FilePickerConst.MEDIA_PICKER ? FilePickerConst.REQUEST_CODE_PHOTO
                    : FilePickerConst.REQUEST_CODE_DOC);
}

From source file:com.devsh.androidlogin.library.GoogleLoginUtil.java

public void signIn(Activity activity) {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
    activity.startActivityForResult(signInIntent, RC_SIGN_IN);
}

From source file:com.firebase.ui.auth.provider.GoogleProvider.java

@Override
public void startLogin(Activity activity) {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    activity.startActivityForResult(signInIntent, RC_SIGN_IN);
}

From source file:com.rks.musicx.misc.utils.permissionManager.java

public static void settingPermission(@NonNull Activity activity) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(activity)) {
        MaterialDialog.Builder builder = new MaterialDialog.Builder(activity).title(R.string.permissions_title)
                .content(R.string.writesetting).positiveText(R.string.btn_continue)
                .negativeText(R.string.btn_cancel).autoDismiss(true)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override//  ww  w  .j a  v  a  2 s  . c  om
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                            Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
                                    Uri.fromParts("package", activity.getPackageName(), null));
                            if (Helper.isActivityPresent(activity, intent)) {
                                activity.startActivityForResult(intent, WRITESETTINGS);
                            } else {
                                Toast.makeText(activity, "No app found to handle settings write permission",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }).onNegative(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        Toast.makeText(activity, R.string.toast_permissions_not_granted, Toast.LENGTH_SHORT)
                                .show();
                        dialog.dismiss();
                    }
                }).neutralText("Never show again").onNeutral(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        Extras.getInstance().setSettings(true);
                        dialog.dismiss();
                    }
                });
        if (activity.hasWindowFocus() || !activity.isFinishing()) {
            builder.show();
        }
    }
}

From source file:org.projectbuendia.client.ui.OdkActivityLauncher.java

/**
 * Shows the form with the given id in ODK collect.
 * @param callingActivity the {@link Activity} requesting the xform; when ODK closes, the user
 *                        will be returned to this activity
 * @param requestCode     if >= 0, this code will be returned in onActivityResult() when the
 *                        activity exits
 * @param formId          the id of the form to fetch
 * @param patient         the {@link org.odk.collect.android.model.Patient} that this form entry will
 *                        correspond to//from  w w  w .  j  av a 2  s.  c om
 * @param fields          a {@link Preset} object with any form fields that should be
 *                        pre-populated
 */
public static void showOdkCollect(Activity callingActivity, int requestCode, long formId,
        @Nullable org.odk.collect.android.model.Patient patient, @Nullable Preset fields) {
    Intent intent = new Intent(callingActivity, FormEntryActivity.class);
    Uri formUri = ContentUris.withAppendedId(FormsProviderAPI.FormsColumns.CONTENT_URI, formId);
    intent.setData(formUri);
    intent.setAction(Intent.ACTION_PICK);
    if (patient != null) {
        intent.putExtra("patient", patient);
    }
    if (fields != null) {
        intent.putExtra("fields", fields);
    }
    callingActivity.startActivityForResult(intent, requestCode);
}

From source file:com.bilibili.boxing.Boxing.java

/**
 * same as {@link Activity#startActivityForResult(Intent, int, Bundle)}
 *//* ww  w.ja v a 2s .c  om*/
public void start(@NonNull Activity activity, int requestCode) {
    activity.startActivityForResult(mIntent, requestCode);
}

From source file:com.rks.musicx.misc.utils.permissionManager.java

public static void widgetPermission(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(activity)) {
        MaterialDialog.Builder dialog = new MaterialDialog.Builder(activity).title(R.string.permissions_title)
                .content(R.string.draw_over_permissions_message).positiveText(R.string.btn_continue)
                .negativeText(R.string.btn_cancel).autoDismiss(true)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override/*  www.j a  v a2  s.  co  m*/
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                                    Uri.fromParts("package", activity.getPackageName(), null));
                            if (Helper.isActivityPresent(activity, intent)) {
                                activity.startActivityForResult(intent, OVERLAY_REQ);
                            } else {
                                Toast.makeText(activity,
                                        "No app found to handle floating widget enable permission",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }).onNegative(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        Toast.makeText(activity, R.string.toast_permissions_not_granted, Toast.LENGTH_SHORT)
                                .show();
                        dialog.dismiss();
                    }
                }).neutralText("Never show again").onNeutral(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        Extras.getInstance().setWidgetTrack(true);
                        dialog.dismiss();
                    }
                });
        if (activity.hasWindowFocus() || !activity.isFinishing()) {
            dialog.show();
        }
    }
}