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 file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);//from ww  w . j a va  2s. com
}

From source file:Main.java

public static void playVideoOrAudio(Context context, Uri uri) {
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*w w  w  .j a va  2 s.  c o m*/
}

From source file:Main.java

public static void startXiaomiApp(Context context) {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.xiaomi.smarthome");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from w w  w .ja va2 s  . com
}

From source file:Main.java

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

From source file:Main.java

public static void InstallApk(Context context, String path) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
    context.startActivity(intent);/* w w w .  ja  va2s  . c  om*/
}

From source file:Main.java

public static Intent showOpenTypeDialog(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, "*/*");
    return intent;
}

From source file:Main.java

public static void oepnSetting(Context context) {
    Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.getApplicationContext().startActivity(intent);
}

From source file:Main.java

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

From source file:Main.java

public static void installApp(Context context, File apkFile) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");

    context.startActivity(intent);//from   w  w w  .ja  v  a 2  s . c  o m
    // YxCfgManager.getYxCfgInstance().write(YxAppCfg.IS_FIRST, true);
}

From source file:Main.java

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