Example usage for android.content Context startActivity

List of usage examples for android.content Context startActivity

Introduction

In this page you can find the example usage for android.content Context startActivity.

Prototype

public abstract void startActivity(@RequiresPermission Intent intent);

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:Main.java

public static void startWebIntent(Context context, String url) {
    try {//from  w w  w  .  j  av a2 s  .c o  m
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(intent);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting url intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app for viewing this url!", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:Main.java

@SuppressLint("NewApi")
public static void doSettings(Context context) {
    Intent intent = new Intent(Settings.ACTION_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void dialog(Context context, String inputStr) {
    Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + inputStr));

    context.startActivity(phoneIntent);

}

From source file:Main.java

public static void openDial(Context getContext, String number) {
    Uri uri = Uri.parse("tel:" + number);
    Intent it = new Intent(Intent.ACTION_DIAL, uri);
    getContext.startActivity(it);
}

From source file:Main.java

/**
 * Start a new Activity with the flag CLEAR_TOP
 *
 * @param context, Context/*from w ww  . j  av a  2s.com*/
 * @param cls,     Class
 */
public static void startActivity(Context context, Class<?> cls) {
    Intent i = new Intent(context, cls);
    //   i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(i);
}

From source file:Main.java

public static void callSystemActionDial(Context context, String phone) {
    Uri uri = Uri.parse("tel:" + phone);
    Intent intent = new Intent(Intent.ACTION_DIAL, uri);
    context.startActivity(intent);
}

From source file:Main.java

public static void openURL(Context mContext, String url) {
    Uri uri = Uri.parse(url);/*from  w  ww .j a v  a 2  s . c o m*/
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    mContext.startActivity(intent);
}

From source file:Main.java

public static void lunchTheApp(String pack, Context context) {
    try {/*from w w w  . ja  v a  2 s  .c  om*/
        Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(pack);
        context.startActivity(LaunchIntent);
    } catch (ActivityNotFoundException e) {

    } catch (Exception e) {
        //NULL pointer for context
    }
}

From source file:Main.java

public static void viewURL(Context context, String url) {
    Intent viewURLIntent = new Intent(Intent.ACTION_VIEW);
    viewURLIntent.setData(Uri.parse(url));
    context.startActivity(viewURLIntent);
}

From source file:Main.java

public static void showExamInBrowser(Context context, String courseId) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_GET_EXAMS));
    context.startActivity(intent);
    // TODO: create activity with webview that uses stored credentials to login and open page with search for courseId
}