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 OpenURL(Context context, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    context.startActivity(browserIntent);
}

From source file:Main.java

public static void gotoActivity(Context ctx, Class<?> c, boolean close) {
    Intent intent = new Intent(ctx, c);
    ctx.startActivity(intent);
    if (close) {/*  ww  w .ja  v a2s .c  o m*/
        ((Activity) ctx).finish();
    }
}

From source file:Main.java

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

From source file:Main.java

public static void makeACall(String phonenUmber, Context context) {
    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phonenUmber));
    context.startActivity(callIntent);
}

From source file:Main.java

public static void startActivity(Context from, Class<?> to, Bundle data) {
    Intent i = new Intent(from, to);
    i.putExtras(data);//from   w  w  w.  ja  v a 2 s. co m
    from.startActivity(i);
}

From source file:Main.java

/**
 * Starts an Activity /*from  w w  w  .j  av  a2s.co  m*/
 * @param ctx The context starting the activity
 * @param target The activity's class to start
 */
public static void launchActivity(Context ctx, Class<? extends Activity> target) {
    Intent i = new Intent(ctx, target);
    ctx.startActivity(i);
}

From source file:Main.java

public static void startAPP(String appPackageName, Context context) {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage(appPackageName);
    context.startActivity(intent);
}

From source file:Main.java

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

From source file:Main.java

public static void openPlayStore(Context context) {
    final String appPackageName = context.getPackageName();
    try {/*from   www . ja  va 2  s  . com*/
        context.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
    } catch (android.content.ActivityNotFoundException anfe) {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
    }
}

From source file:Main.java

/**
 * Launches a browser to the specified URL.
 *
 * @param context Android context//from   w  w  w.ja v  a 2s. c  om
 * @param url URL to browse to
 */
public static void launchToUrl(final Context context, final Uri url) {
    final Intent intent = new Intent(Intent.ACTION_VIEW, url);
    context.startActivity(intent);
}