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,
        @Nullable Bundle options) 

Source Link

Document

Launch an activity for which you would like a result when it finished.

Usage

From source file:com.maskyn.fileeditorpro.util.AnimationUtils.java

public static void startActivityWithScale(@NonNull Activity startActivity, @NonNull Intent subActivity,
        @NonNull boolean forResult, @Nullable int code, @NonNull View view) {
    if (forResult) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
            startActivity.startActivityForResult(subActivity, code, AnimationUtils.getScaleBundle(view));
        else/*from   w w w  . jav  a 2s  .  c o  m*/
            startActivity.startActivityForResult(subActivity, code);
    } else {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
            startActivity.startActivity(subActivity, AnimationUtils.getScaleBundle(view));
        else
            startActivity.startActivity(subActivity);
    }
}

From source file:Main.java

private static void startActivityForResult(final Intent intent, final Activity activity, final int requestCode,
        final Bundle options) {
    if (options != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        activity.startActivityForResult(intent, requestCode, options);
    } else {// w  w w . j a  v  a2s . c  o  m
        activity.startActivityForResult(intent, requestCode);
    }
}

From source file:com.github.piasy.safelyandroid.activity.StartActivityDelegate.java

/**
 * start activity for result from {@link Activity}
 *
 * @param activity activity we start from
 * @param intent intent to start//  w  w w  . j  a  va  2s.com
 * @param requestCode request code
 * @param options options used to start activity
 * @return {@code true} if we start it safely, {@code false} if it's unsafe so we didn't start
 * it
 */
public static boolean startActivityForResultSafely(@NonNull Activity activity, @NonNull Intent intent,
        int requestCode, Bundle options) {
    if (isIntentSafe(activity.getPackageManager(), intent)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            activity.startActivityForResult(intent, requestCode, options);
        } else {
            activity.startActivityForResult(intent, requestCode);
        }
        return true;
    }
    return false;
}

From source file:com.devalladolid.musictoday.utils.NavigationUtils.java

@TargetApi(21)
public static void navigateToPlaylistDetail(Activity context, String action, long firstAlbumID,
        String playlistName, int foregroundcolor, long playlistID, ArrayList<Pair> transitionViews) {
    final Intent intent = new Intent(context, PlaylistDetailActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }/*from www . j  a  v  a 2s.c om*/
    intent.setAction(action);
    intent.putExtra(Constants.PLAYLIST_ID, playlistID);
    intent.putExtra(Constants.PLAYLIST_FOREGROUND_COLOR, foregroundcolor);
    intent.putExtra(Constants.ALBUM_ID, firstAlbumID);
    intent.putExtra(Constants.PLAYLIST_NAME, playlistName);
    intent.putExtra(Constants.ACTIVITY_TRANSITION, transitionViews != null);

    if (transitionViews != null && TimberUtils.isLollipop()
            && PreferencesUtility.getInstance(context).getAnimations()) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.getInstance(),
                transitionViews.get(0), transitionViews.get(1), transitionViews.get(2));
        context.startActivityForResult(intent, Constants.ACTION_DELETE_PLAYLIST, options.toBundle());
    } else {
        context.startActivityForResult(intent, Constants.ACTION_DELETE_PLAYLIST);
    }
}

From source file:de.schildbach.wallet.ui.scan.ScanActivity.java

public static void startForResult(final Activity activity, @Nullable final View clickView,
        final int requestCode) {
    if (clickView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final int[] clickViewLocation = new int[2];
        clickView.getLocationOnScreen(clickViewLocation);
        final Intent intent = new Intent(activity, ScanActivity.class);
        intent.putExtra(ScanActivity.INTENT_EXTRA_SCENE_TRANSITION_X,
                (int) (clickViewLocation[0] + clickView.getWidth() / 2));
        intent.putExtra(ScanActivity.INTENT_EXTRA_SCENE_TRANSITION_Y,
                (int) (clickViewLocation[1] + clickView.getHeight() / 2));
        final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity, clickView,
                "transition");
        activity.startActivityForResult(intent, requestCode, options.toBundle());
    } else {//from  w  w  w .  j ava  2  s .  c o m
        startForResult(activity, requestCode);
    }
}

From source file:de.dreier.mytargets.utils.IntentWrapper.java

private void start(Activity activity) {
    if (Utils.isLollipop()) {
        if (requestCode == null) {
            activity.startActivity(intent, options);
        } else {/*w w  w . j  a v  a  2 s.  com*/
            activity.startActivityForResult(intent, requestCode, options);
        }
    } else {
        if (requestCode == null) {
            activity.startActivity(intent);
        } else {
            activity.startActivityForResult(intent, requestCode);
        }
    }
}