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 unInstallApk(Context context, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    context.startActivity(uninstallIntent);
}

From source file:Main.java

public static void openSendMsg(Context getContext) {
    Uri uri = Uri.parse("smsto:");
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getContext.startActivity(intent);
}

From source file:Main.java

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

From source file:Main.java

public static void gotoMarket(Context context, String pck) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=" + pck));
    context.startActivity(intent);
}

From source file:Main.java

public static void openWeb(Context context, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));/*from  w w  w.  j  av a  2  s  .  co  m*/
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void callPhone(Context context, String phoneNumber) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:" + phoneNumber));
    context.startActivity(intent);
}

From source file:Main.java

/**
 * use to show address location pin on map.
 *
 * @param mContext//from   w w w. java  2 s. c  om
 * @param address  to show on map.
 */
public static void showAddressOnMap(Context mContext, String address) {
    address = address.replace(' ', '+');
    Intent geoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
    mContext.startActivity(geoIntent);
}

From source file:Main.java

public static void unInstallApkFromPackage(Context context, String apk_pkg) {
    try {/*www. j  a  v  a 2  s  .  c o  m*/
        Intent intent = new Intent(Intent.ACTION_DELETE);
        intent.setData(Uri.parse("package:" + apk_pkg));
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.parse("package:" + packageName);
    intent.setData(data);/*from ww  w  .ja va2  s.  c om*/
    context.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Context context, Class cls, String nameFlag, Serializable serializable) {
    Intent intent = new Intent(context, cls);
    intent.putExtra(nameFlag, serializable);
    context.startActivity(intent);
}