Example usage for android.content Intent setFlags

List of usage examples for android.content Intent setFlags

Introduction

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

Prototype

public @NonNull Intent setFlags(@Flags int flags) 

Source Link

Document

Set special flags controlling how this intent is handled.

Usage

From source file:Main.java

public static void setSingleClearTop(Intent intent) {
    intent.setFlags(0x24000000);
}

From source file:Main.java

private static void removeFlag(Intent intent, int flag) {
    intent.setFlags(intent.getFlags() & ~flag);
}

From source file:Main.java

public static Intent getInstallApkIntent(File file) {
    Intent intent = new Intent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    return intent;
}

From source file:Main.java

public static <T> void startService(Context context, Class<T> clazz) {
    Intent i = new Intent(context, clazz);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startService(i);/*from w w  w .  j a va 2  s . c o  m*/
}

From source file:Main.java

public static void installAPK(Context context, File file) {
    if (file == null || !file.exists())
        return;/*from ww w .j  ava  2s.  co m*/
    Intent intent = new Intent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

public static void startActivityAndClear(Context act, Class<?> cls) {
    Intent intent = new Intent(act, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    act.startActivity(intent);/*w  ww  .  j a v a 2s.c om*/
}

From source file:Main.java

public static void startMainActivity(Context context) {
    Intent intent = new Intent("MAIN_ACTIVITY");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*www . jav a 2  s .co m*/
}

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 a 2 s  .c  o  m*/
}

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);//from w  ww . jav a2  s .  c o m
}

From source file:Main.java

public static void openDail(Context getContext) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getContext.startActivity(intent);/*from w w w.j  av  a2 s. c  o m*/
}