Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

In this page you can find the example usage for android.content Intent addFlags.

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:Main.java

public static void installApkByPath(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);//from  w ww  .j  a va 2s  . com
}

From source file:Main.java

public static void install(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);//from   w ww . j ava 2  s .com
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static boolean install(Context context, File file) {
    if (file == null || !file.exists() || !file.isFile()) {
        return false;
    }//from   w  w w. ja va2  s .  com
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    return true;
}

From source file:Main.java

public static void restartApp(Activity activity) {
    if (activity == null) {
        return;// ww  w  .j  a  v a2s .  c om
    }
    Intent i = activity.getBaseContext().getPackageManager()
            .getLaunchIntentForPackage(activity.getBaseContext().getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(i);
    activity.finish();
}

From source file:Main.java

public static Intent getSettingLSWallpaperIntent() {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.asus.launcher", "com.asus.themeapp.ThemeAppActivity"));
    intent.addFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("tabPosition", 1);
    return intent;
}

From source file:Main.java

public static Intent getSettingLSThemeIntent() {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.asus.themeapp", "com.asus.themeapp.ThemeAppActivity"));
    intent.addFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("from", "com.android.systemui.lockscreen");
    return intent;
}

From source file:Main.java

public static Intent getPermissionmanagerIntent() {
    Intent intent = new Intent();
    intent.setClassName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static Intent getLeSafeMainActivityIntent() {
    Intent intent = new Intent();
    intent.setClassName("com.lenovo.safecenter", "com.lenovo.safecenter.MainTab.LeSafeMainActivity");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}