Example usage for android.app Fragment startActivity

List of usage examples for android.app Fragment startActivity

Introduction

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

Prototype

public void startActivity(Intent intent, Bundle options) 

Source Link

Document

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

Usage

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

/**
 * start activity from {@link android.app.Fragment}
 *
 * @param fragment fragment we start from
 * @param intent intent to start/*from   w w  w  .  j a  v  a2 s  . c om*/
 * @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 startActivitySafely(@NonNull android.app.Fragment fragment, @NonNull Intent intent,
        Bundle options) {
    if (isIntentSafe(fragment.getActivity().getPackageManager(), intent)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            fragment.startActivity(intent, options);
        } else {
            fragment.startActivity(intent);
        }
        return true;
    }
    return false;
}