Example usage for android.content Intent FLAG_ACTIVITY_NEW_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_NEW_TASK.

Prototype

int FLAG_ACTIVITY_NEW_TASK

To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.

Click Source Link

Document

If set, this activity will become the start of a new task on this history stack.

Usage

From source file:Main.java

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

From source file:Main.java

public static void installApkByPath(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);//  w w  w  . j ava2 s.  co m
}

From source file:Main.java

public static void startUnistalledApp(Context mContext, String pkgName) {
    Uri packageUri = Uri.parse("package:" + pkgName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
    uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(uninstallIntent);

}

From source file:Main.java

public static void sendEmail(Context context, String receiver, String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { receiver });
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    try {// w  w  w  .j a va2 s . com
        context.startActivity(Intent.createChooser(intent, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
    }
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void install(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//  ww  w .j  a v a 2s  . co m
}

From source file:Main.java

private static void startActivityByResolve(Context context, ResolveInfo r, Intent intent) {
    Intent intent2 = new Intent(intent);
    intent2.setClassName(r.activityInfo.packageName, r.activityInfo.name);
    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.getApplicationContext().startActivity(intent2);
}

From source file:Main.java

public static void doCall(Activity aty, String mobile) throws Exception {
    if (null != aty && null != mobile) {
        Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + mobile));
        phoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        aty.startActivity(phoneIntent);/*  w  ww  .  ja va2 s . c o m*/
    }
}

From source file:Main.java

public static void unInstallPackage(Context context, String packageName) {
    Uri packageUri = Uri.fromParts("package", packageName, null);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
    uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(uninstallIntent);
}