Example usage for android.app Activity startActivityIfNeeded

List of usage examples for android.app Activity startActivityIfNeeded

Introduction

In this page you can find the example usage for android.app Activity startActivityIfNeeded.

Prototype

public boolean startActivityIfNeeded(@RequiresPermission @NonNull Intent intent, int requestCode) 

Source Link

Document

Same as calling #startActivityIfNeeded(Intent,int,Bundle) with no options.

Usage

From source file:Main.java

public static void openBrowser(Activity activity, String url) {
    final Uri uri = Uri.parse(url);
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    activity.startActivityIfNeeded(intent, 0);
}

From source file:org.kontalk.ui.PreferencesActivity.java

public static void start(Activity context) {
    Intent intent = new Intent(context, PreferencesActivity.class);
    context.startActivityIfNeeded(intent, -1);
}

From source file:com.songcode.materialnotes.ui.NotesListActivity.java

private void startPreferenceActivity() {
    Activity from = getParent() != null ? getParent() : this;
    Intent intent = new Intent(from, NotesPreferenceActivity.class);
    from.startActivityIfNeeded(intent, -1);
}