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 installApk(Context context, File filename) {
    Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.fromFile(filename));
    context.startActivity(intent);//from ww  w. j  av  a  2s . co m
}

From source file:Main.java

public static void unInstallApp(Context context, String packageName) {
    Uri packageUri = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, packageUri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from  w  w  w  .  ja v  a  2s.c om
}

From source file:Main.java

public static void goToAccessibilitySetting(Context context) {
    context.startActivity(//from   www .  j  a v  a  2  s .  c  o m
            new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, packageURI);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*  w w  w.j a v  a 2  s  .  c o m*/
}

From source file:Main.java

public static void uninstallAppbyPackageName(Context context, String packageName) {
    Uri uri = Uri.parse("package:" + packageName);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*w  ww.  j a  va2 s.  c om*/
}

From source file:Main.java

public static final Intent buyFullIntent() {
    Uri fullVersionURI = Uri.parse("market://details?id=net.fhtagn.zoobgame");
    Intent i = new Intent(Intent.ACTION_VIEW, fullVersionURI);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return i;// www.j a v  a 2s  .  c  om
}

From source file:Main.java

public static void startActivityClearTask(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);//w w w.  ja v  a2  s .  c o m
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

public static void takeMyselfToForeground(Context context, Class launcher) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClass(context, launcher);/*from   w  w w .  ja va2s. c  om*/
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(intent);
}

From source file:Main.java

public static void installApk(Context context, File file) {
    if (!file.exists()) {
        return;/*  w w w .j  a v  a  2  s .  c o  m*/
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

public static Intent createLaunchIntent(ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(componentName);//from w  w w  .j a  v a2  s .  c  o  m
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}