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 sendSms(Context context, String phoneNum, String content) {
    Intent mIntent = new Intent(Intent.ACTION_VIEW);
    mIntent.putExtra("address", phoneNum);
    mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mIntent.putExtra("sms_body", content);
    mIntent.setType("vnd.android-dir/mms-sms");
    context.startActivity(mIntent);/*  ww  w  .j  ava  2  s  .  c  o  m*/
}

From source file:Main.java

static void showDesktop(Context ctx) {
    Intent mHomeIntent;//  w  w w .  j a  v  a2  s. c o  m
    mHomeIntent = new Intent(Intent.ACTION_MAIN, null);
    mHomeIntent.addCategory(Intent.CATEGORY_HOME);
    mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    ctx.startActivity(mHomeIntent);
}

From source file:Main.java

private static void uninstallAppByClick(Context context, String pkgName) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("package:" + pkgName));
    context.startActivity(intent);// w ww  . ja va  2s  .  c o  m
}

From source file:Main.java

public static void dial(Context context, String number) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + number));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from ww  w  .  jav a  2  s  .  co m
}

From source file:Main.java

public static void startActivityMarketOnCutinManagerPage(Context context) {
    Intent intent = buildMarketIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from w w w  . j  av a2s .  co m*/
}

From source file:Main.java

public static String unInstallBySys(Context context, String pckName) {
    Intent intent = new Intent();
    Uri uri = Uri.parse("package:" + pckName);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(uri);//w  ww . j  a  v a2  s  . co m
    context.startActivity(intent);
    return null;
}

From source file:Main.java

public static boolean installApk(Context context, String archiveFilePath) {
    try {//from w ww  . j  a v  a  2 s  .  co  m
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.parse("file:///" + archiveFilePath),
                "application/vnd.android.package-archive");
        context.startActivity(intent);
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static Intent getPdfFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "application/pdf");
    return intent;
}

From source file:Main.java

public static Intent getAllFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "*/*");
    return intent;
}

From source file:Main.java

public static Intent getWordFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "application/msword");
    return intent;
}