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 shareText(Context context, String title, String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// Intent.createChooser(intent, title)
}

From source file:Main.java

public static void openYYB2(Context context) {

    Intent intent2 = new Intent();
    intent2.setComponent(new ComponentName("com.tencent.android.qqdownloader",
            "com.connector.tencent.connector.ConnectionActivity"));
    intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent2);/*from ww  w  . j a v  a  2s .c om*/

}

From source file:Main.java

public static void applyPermission(Context context) {
    Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
    intent.setClassName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity");
    intent.putExtra("packageName", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/* www.  ja  v  a  2s  .com*/
}

From source file:Main.java

public static void toScores(Context context) {
    try {//from w w w. ja v a 2s .co  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

/**
 * start home intent/*w  w w .  ja va2  s.  com*/
 *
 * @param context
 */
public static void startHomeActivity(Context context) {
    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(homeIntent);
}

From source file:Main.java

/**
 * Minimizes the app/*from   w ww .j a v  a2  s.c o m*/
 * @param context the context
 */
public static void minimizeApp(Context context) {
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(startMain);
}

From source file:Main.java

public static void shareToGMail(Context context, String[] email, String subject, String content) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, email);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content);
    final PackageManager pm = context.getPackageManager();
    final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0);
    ResolveInfo best = null;/*from w  w w  . j  a  v a  2  s  . co  m*/
    for (final ResolveInfo info : matches)
        if (info.activityInfo.packageName.endsWith(".gm")
                || info.activityInfo.name.toLowerCase().contains("gmail"))
            best = info;
    if (best != null)
        emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name);
    context.startActivity(emailIntent);
}

From source file:Main.java

public static Intent getInstallIntent(File apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(apkFile.getAbsolutePath())),
            "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static void install(Context context, File uriFile) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(uriFile), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/* w w w  . ja v  a 2  s.c  o  m*/
}

From source file:Main.java

public static boolean uninstallApk(Context context, String packageName) {
    if (TextUtils.isEmpty(packageName)) {
        return false;
    }/*  www.jav  a2  s. c  o  m*/
    Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + packageName));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}