Example usage for android.app Fragment startActivityForResult

List of usage examples for android.app Fragment startActivityForResult

Introduction

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

Prototype

public void startActivityForResult(Intent intent, int requestCode, Bundle options) 

Source Link

Document

Call Activity#startActivityForResult(Intent,int,Bundle) from the fragment's containing Activity.

Usage

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

/**
 * start activity for result from {@link android.app.Fragment}
 *
 * @param fragment fragment we start from
 * @param intent intent to start//from  ww w.  j a va2 s  . c  o  m
 * @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 android.app.Fragment fragment,
        @NonNull Intent intent, int requestCode, Bundle options) {
    if (isIntentSafe(fragment.getActivity().getPackageManager(), intent)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            fragment.startActivityForResult(intent, requestCode, options);
        } else {
            fragment.startActivityForResult(intent, requestCode);
        }
        return true;
    }
    return false;
}