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 unInstallApp(Context context, String packageName) {
    Uri packageUri = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, packageUri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, packageURI);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:com.example.awesomedogs.ui.DogDetailActivity.java

static void startActivity(Context context, String id) {
    Intent intent = new Intent(context, DogDetailActivity.class);
    intent.putExtra(EXTRA_DOG_ID, id);// w  w w .  ja v  a  2s  . co m
    context.startActivity(intent);
}

From source file:Main.java

public static void installAPK(Context context, String apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);

    intent.setDataAndType(Uri.fromFile(new File(apkFile)), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

public static Boolean sendSms(Context mContext, String smstext) {
    Uri smsToUri = Uri.parse("smsto:");
    Intent mIntent = new Intent(android.content.Intent.ACTION_SENDTO, smsToUri);
    mIntent.putExtra("sms_body", smstext);
    mContext.startActivity(mIntent);
    return null;// w ww . j  a va  2 s .c om
}

From source file:Main.java

public static void uninstallApp(Context context, String packageName) {
    Uri uri = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * Avvia una nuova activity//from  w w w . j av  a2 s  .  c  o m
 * @param context
 * @param activityClass
 * @param params
 */
public static void startActivity(Context context, Class<? extends Activity> activityClass, Bundle params) {
    Intent intent = new Intent(context, activityClass);
    if (params != null)
        intent.putExtras(params);
    context.startActivity(intent);
}

From source file:Main.java

public static void goProgram(Context context, String pkg, String fullclasspath) {
    Intent intent = new Intent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(new ComponentName(pkg, fullclasspath));
    context.startActivity(intent);
}

From source file:Main.java

/**
 * uninstall app via package name// w ww.  j a v a  2s  . c o  m
 * @param context
 * @param packageName
 */
public static void uninstallApp(Context context, String packageName) {
    Uri packageUri = Uri.parse("package:" + packageName);
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(packageUri);
    context.startActivity(intent);
}

From source file:Main.java

public static void openView(Context context, String url) {
    try {//  www. j  ava 2 s.  c om
        Intent intentUri = new Intent(Intent.ACTION_VIEW);
        intentUri.setData(Uri.parse(url));
        intentUri.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intentUri);
    } catch (Exception e) {
    }
}