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 startActivity(Context context, Class<?> c, boolean clearStack) {
    Intent intent = new Intent(context, c);
    if (clearStack)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);
}

From source file:Main.java

public static void rateApplication(Context context) {
    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    try {/*w w  w .  ja v  a  2  s. c  om*/
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        //            UtilityClass.showAlertDialog(context, ERROR, "Couldn't launch the market", null, 0);
    }
}

From source file:Main.java

public static void clearDefaultBrowser(Context context, String packgeName) {
    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
            Uri.parse("package:" + packgeName));
    context.startActivity(intent);
}

From source file:Main.java

public static void chooseHomeApp(Context context) {
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(startMain);
}

From source file:Main.java

public static void openActivity(Context context, Class<?> activity, Bundle b) {
    Intent intent = new Intent(context, activity);
    if (b != null)
        intent.putExtras(b);/*from  w  w w  .j av  a  2 s  .com*/

    context.startActivity(intent);
}

From source file:Main.java

public static void clearActivityTask(final Context context) {
    Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(i);
    ((Activity) context).finish();//from  w ww .  j a  v a2  s  .co  m

}

From source file:Main.java

public static void turnToActivityWithData(Context context, Class activityClass, Serializable bean) {
    Intent intent = new Intent();
    intent.putExtra(data_flag, bean);/*from w  w w  .j  av a 2  s.  c  om*/
    intent.setClass(context, activityClass);
    context.startActivity(intent);
}

From source file:Main.java

public static void showWebPage(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri uri = Uri.parse(url);//from w w w.j a  va 2s.c o  m
    intent.setData(uri);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * "Exits" the app to the Home screen".//from w  ww  .j ava2  s  .co  m
 * @param context Application context
 */
public static void exitToHome(final Context context) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void call(String phoneNum, Context context) throws Exception {//TODO tobe test
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phoneNum));
    context.startActivity(intent);
}