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 openBrowser(Context context, String url) {
    if (!TextUtils.isEmpty(url)) {
        if (!url.startsWith("http://") && !url.startsWith("https://")) {
            url = "http://" + url;
        }//from  ww w.  j  av a2 s  . c  o m
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    } else {
        Log.e("Helpers#openBrowser", "Something isn't right about the URL passed");
    }
}

From source file:Main.java

public static void openMark(Context context) {
    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void openActivity(Context context, Class<Activity> cls) {
    if (null == context || null == cls)
        return;/*www.  j  a  va 2  s  .  c om*/

    Intent i = new Intent(context, cls);
    i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    context.startActivity(i);
}

From source file:Main.java

public static void startActivity(Context mContext, Class className) {
    Intent intent = new Intent();
    intent.setClass(mContext, className);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(intent);
}

From source file:Main.java

public static void goMainActivity(Context context) {
    Intent intent = new Intent();
    intent.setClassName("com.nearucenterplaza.redenvelopeassistant",
            "com.nearucenterplaza.redenvelopeassistant.ui.activity.HomeActivity");
    context.startActivity(intent);
}

From source file:Main.java

public static void sendIntent(Context context, Class classes, String key, String value) {
    Intent intent = new Intent();
    intent.setClass(context, classes);/*www  . j  ava 2  s .c o m*/
    intent.putExtra(key, value);
    context.startActivity(intent);
}

From source file:Main.java

public static void front(Context packageContext, Class<?> cls) {
    Intent intent = new Intent(packageContext, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    packageContext.startActivity(intent);
    intent = null;/*from   w  w w .j a v a  2s  .c o  m*/
}

From source file:Main.java

public static void installAPK(Context context, File apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

public static void imitateHome(Context context) {
    try {//from w  w  w .  j  a va 2s .  c  om
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        context.startActivity(intent);
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:Main.java

public static void sharePic(Uri uri, String desc, Context context) {

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    context.startActivity(Intent.createChooser(shareIntent, desc));
}