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 callPhone(Context mContext, String phoneNumber) {
    Uri uri = Uri.parse("tel:" + phoneNumber);
    Intent call = new Intent(Intent.ACTION_CALL, uri);
    mContext.startActivity(call);
}

From source file:Main.java

public static void startActivity(Context context, Class cls, int intentflag) {
    Intent intent = new Intent(context, cls);
    intent.addFlags(intentflag);/*from w ww  . ja  v a2s. c o  m*/
    context.startActivity(intent);
}

From source file:Main.java

public static boolean openAppByPackageName(Context context, String packageName) {
    Intent intent = getIntentByPackageName(context, packageName);
    if (intent != null) {
        context.startActivity(intent);
        return true;
    }//from  www .  jav  a  2 s  .  co  m
    return false;
}

From source file:Main.java

public static void launchActivity(Context context, Class<?> activity) {
    Intent intent = new Intent(context, activity);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivity(intent);
}

From source file:Main.java

public static void sendEmail(Context context, String receiver) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:" + receiver));
    context.startActivity(intent);
}

From source file:Main.java

public static void enableAccess(Context context) {
    Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static final void viewImageFromUri(Context ctx, Uri u) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(u, "image/*");
    ctx.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Context context, Class activityClass) {
    Intent intent = new Intent(context, activityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void startLauncher(Context context) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(intent);
}

From source file:Main.java

public static void loadUrlInExternalBrowser(Context context, String url) {
    try {/*from ww  w . jav  a2 s .c  om*/
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(browserIntent);
    } catch (Exception ignored) {
    }
}