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.lvbo.template.common.Utils.PermissionUtils.java

/**
 * WRITE_SETTINGS ??// w w w  .  ja v a2s.  c o  m
 * @param cxt
 * @param req
 * @return
 */
@TargetApi(23)
public static boolean checkSettingSystemPermission(Object cxt, int req) {
    if (cxt instanceof Activity) {
        Activity activity = (Activity) cxt;
        if (!Settings.System.canWrite(activity)) {
            Log.i(TAG, "Setting not permission");

            Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + activity.getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            activity.startActivityForResult(intent, req);
            return false;
        }
    } else if (cxt instanceof Fragment) {
        Fragment fragment = (Fragment) cxt;
        if (!Settings.System.canWrite(fragment.getContext())) {
            Log.i(TAG, "Setting not permission");

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

    return true;
}

From source file:com.mycelium.wallet.activity.export.DecryptPrivateKeyActivity.java

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

From source file:devfigas.com.neverlargeexception.SuperIntent.java

protected static SuperIntent receiveForResult(SuperIntent superIntent, Activity from, int requestCode) {
    SuperIntent plusIntent = new SuperIntent();
    plusIntent.mBundle = (Bundle) superIntent.getBundle().clone();
    try {//from  w w w .j  av a  2  s. c om
        superIntent.getBundleExtra(EXTRAS).clear();
    } catch (NullPointerException npe) {
        throw new NullPointerException("SuperIntent not builded: call method build() before to try start");
    }
    from.startActivityForResult(superIntent, requestCode);
    return plusIntent;
}

From source file:com.ouyangzn.github.utils.Actions.java

/**
 * ?fragment/*from ww w  .  j a  va  2 s . com*/
 *
 * @param activity ?activity
 * @param clazz fragment
 * @param bundle ??
 * @param requestCode ?
 */
public static void startActivity(Activity activity, Class<? extends BaseFragment> clazz, Bundle bundle,
        int requestCode) {
    Intent intent = new Intent(activity.getApplicationContext(), BaseFragmentActivity.class);
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    intent.putExtra(BaseFragmentActivity.DATA_FRAGMENT_NAME, clazz.getName());
    activity.startActivityForResult(intent, requestCode);
}

From source file:com.github.kanata3249.ffxieq.android.VWAtmaSelectorActivity.java

static public boolean startActivity(Activity from, int request, FFXICharacter charInfo, int index,
        long current) {
    Intent intent = new Intent(from, VWAtmaSelectorActivity.class);

    intent.putExtra("Current", current);
    intent.putExtra("Index", index);
    intent.putExtra("Filter", (long) -1);

    from.startActivityForResult(intent, request);
    return true;// www . j  av  a2  s  .  c  o m
}

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

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

From source file:com.teleca.jamendo.activity.BrowsePlaylistActivity.java

/**
 * Save playlist, launch as a subActivity
 * /*  w  w  w .  ja  va2 s  .co  m*/
 * @param a
 * @param playlist
 */
public static void launchSave(Activity a, Playlist playlist) {
    Intent intent = new Intent(a, BrowsePlaylistActivity.class);
    intent.putExtra("mode", Mode.Save);
    intent.putExtra("playlist", playlist);
    a.startActivityForResult(intent, SAVE_REQUEST_CODE);
}

From source file:net.canking.permissiondemo.PermissionUtils.java

/**
 * WRITE_SETTINGS ??/*  w w w  .  java 2s  .co m*/
 * @param cxt
 * @param req
 * @return
 */
@TargetApi(23)
public static boolean checkSettingSystemPermission(Object cxt, int req) {
    if (cxt instanceof Activity) {
        Activity activity = (Activity) cxt;
        if (!Settings.System.canWrite(activity)) {
            Log.i(TAG, "Setting not permission");

            Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + activity.getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            activity.startActivityForResult(intent, req);
            return false;
        }
    } else if (cxt instanceof Fragment) {
        Fragment fragment = (Fragment) cxt;
        if (!Settings.System.canWrite(fragment.getContext())) {
            Log.i(TAG, "Setting not permission");

            Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + fragment.getContext().getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            fragment.startActivityForResult(intent, req);
            return false;
        }
    } else {
        throw new RuntimeException("cxt is net a activity or fragment");
    }

    return true;
}

From source file:com.github.kanata3249.ffxieq.android.FoodSelectorActivity.java

static public boolean startActivity(Activity from, int request, FFXICharacter charInfo, long current) {
    Intent intent = new Intent(from, FoodSelectorActivity.class);

    intent.putExtra("Current", current);
    intent.putExtra("Filter", (long) -1);
    intent.putExtra("FilterByType", "");

    from.startActivityForResult(intent, request);
    return true;// w ww  .j a va 2s .  c  o  m
}

From source file:com.github.kanata3249.ffxieq.android.AugmentEditActivity.java

static public boolean startActivity(Activity from, int request, FFXICharacter charInfo, int part, long baseID,
        long augID) {
    Intent intent = new Intent(from, AugmentEditActivity.class);

    intent.putExtra("Part", part);
    intent.putExtra("BaseId", baseID);
    intent.putExtra("AugId", augID);

    from.startActivityForResult(intent, request);
    return true;//from   w w w . j  a v a  2s  .  c  om
}