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 Intent getApkFileIntent(String param) {

    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "application/vnd.android.package-archive");
    return intent;
}

From source file:Main.java

public static void goHome(Activity parent) {
    Intent i = new Intent(parent, Main.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_ACTIVITY_NEW_TASK);
    parent.startActivity(i);/*from   w  ww. j av  a  2  s .c  o m*/
}

From source file:Main.java

public static void front(Context packageContext, Class<?> cls) {
    Intent intent = new Intent(packageContext, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    packageContext.startActivity(intent);
    intent = null;//from ww w  . ja v a2 s .  c om
}

From source file:Main.java

public static <T> void jump2interface(Context context, Class<T> where) {
    Intent intent = new Intent(context, where);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from  w  w  w .  ja v  a2 s . com
}

From source file:Main.java

public static void installApk(Context context, Uri file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(file, "application/vnd.android.package-archive");
    context.startActivity(intent);/*from w w w  . j a  v a  2 s  .  com*/
}

From source file:Main.java

public static void startActivity(Context context, Class activityClass) {
    Intent intent = new Intent(context, activityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from w ww .  ja va 2  s  .  c om*/
}

From source file:Main.java

private static Intent getNormalCameraIntent() {
    Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static void jumpToSystemSetting(Context context) {
    Intent intent = new Intent("acton.settings.personal.ServicePhone");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from w  ww .  j  a  v a2s  .co  m
}

From source file:Main.java

public static void imitateHome(Context context) {
    try {//from  ww  w  .java 2 s .c om
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        context.startActivity(intent);
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:Main.java

public static void toHome(Context context) {
    Intent i = new Intent(Intent.ACTION_MAIN);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(i);//w  w w .j a  v a  2  s. co m
}