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

static void resolveIntent(Intent intent, Context context) {
    if (context instanceof Application) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    }//from w  w  w  . j a  v  a  2  s.  c  o  m
    context.startActivity(intent);
}

From source file:Main.java

private static Intent createCalendarIntent(String action) {
    Intent intent = new Intent();
    intent.setAction(action);/*from   ww w  .j  av a  2s  .c o  m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

From source file:Main.java

public static Intent getDialIntent(String phoneNumber) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static void startIntentWithoutHistory(Activity activity, Class intentClass) {
    Intent intent = new Intent(activity, intentClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);//from ww w.j a va  2  s  .c om
}

From source file:Main.java

public static void installApp(Context context, String path) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + path), "application/vnd.android.package-archive");
    context.startActivity(intent);//from   w w w .j  av  a  2s  . c om
}

From source file:Main.java

public static boolean backToHome(Context c) {
    Intent i = new Intent(Intent.ACTION_MAIN);

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_HOME);

    c.startActivity(i);/*  ww w.java 2s  .  co  m*/

    return true;
}

From source file:Main.java

public static void install(Activity activity, File apk_file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apk_file), "application/vnd.android.package-archive");
    activity.startActivity(intent);//from   w  w  w . j a  v a  2 s .  c  o  m
}

From source file:Main.java

public static <T> void jumpActivityNewTask(Activity activity, Class<T> targetActivity) {
    Intent intent = new Intent(activity, targetActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);//w  w w . j a  v a 2s.  c o m
}

From source file:Main.java

public static void installApk(Context context, String apkPath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive");
    context.startActivity(intent);//  ww  w.  ja  va2  s . c  o m
}

From source file:Main.java

public static void installBySys(Context context, File f) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
    context.startActivity(intent);/*  w ww  .ja  v  a2  s  .c  o m*/
}