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 callSms(Context context, String number, String content) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SENDTO);
    intent.putExtra("sms_body", content);
    intent.setData(Uri.parse(String.format("smsto:%s", number)));
    context.startActivity(intent);
}

From source file:Main.java

public static void toScores(Context context) {
    try {/*from  w w  w . ja  v  a 2 s.c  o  m*/
        Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void startMobileDataSettingActivity(Context context) {
    Intent mIntent = new Intent("/");
    ComponentName comp = new ComponentName("com.android.phone", "com.android.phone.Settings");
    mIntent.setComponent(comp);//from   www.  j a v a  2 s  .com
    mIntent.setAction("android.intent.action.VIEW");
    context.startActivity(mIntent);
}

From source file:mah.farmer.ui.ProductInfoActivity.java

public static void start(Context c) {
    c.startActivity(new Intent(c, ProductInfoActivity.class));
}

From source file:Main.java

public static void install(Context context, String filePath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(new File(filePath)), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Context context, String packagename) {
    try {//from   ww  w. java 2  s  .  c  o  m
        PackageManager packageManager = context.getPackageManager();
        Intent intent = packageManager.getLaunchIntentForPackage(packagename);
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void shareFile(Context context, String title, String filePath) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    Uri uri = Uri.parse("file://" + filePath);
    intent.setType("*/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(intent, title));
}

From source file:Main.java

public static void openAppDetails(Context context, String pkgname) {
    Intent i = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    Uri data = Uri.parse("package:" + pkgname);
    i.setData(data);/*w  w w .  j  a  v a  2 s  . co  m*/
    context.startActivity(i);
}

From source file:Main.java

public static void uninstallApp(Context context, String packageName) {
    // Create new intent to launch Uninstaller activity
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    context.startActivity(uninstallIntent);
}