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 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;//w  w  w  .  j a v  a 2s .c  o m
}

From source file:Main.java

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

From source file:Main.java

public static boolean backToHome(Context c) {
    Intent i = new Intent(Intent.ACTION_MAIN);

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_HOME);

    c.startActivity(i);/*from w w  w.  j  a  v a  2  s .c om*/

    return true;
}

From source file:Main.java

public static <T> void jumpActivityNewTask(Activity activity, Class<T> targetActivity) {
    Intent intent = new Intent(activity, targetActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);//from ww w .  j  a  v a2s .com
}

From source file:Main.java

public static void jumpToNewTopActivity(Context context, Class<? extends Activity> targetClass) {
    Intent datatIntent = new Intent(context, targetClass);
    datatIntent.setFlags(335544320);
    context.startActivity(datatIntent);//from ww w  .  ja  va2  s  .  c o  m
}

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);/*from w  ww  .  ja va  2 s  .  c  o  m*/
}

From source file:Main.java

public static void Instanll(File file, Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(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);//  w w w  . j  a  v a  2  s.  c  om
}

From source file:Main.java

public static void updateSys(Context context, String filePath) {
    Uri iru = Uri.fromFile(new File(filePath));
    Intent inten = new Intent(Intent.ACTION_VIEW);
    inten.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    inten.setDataAndType(iru, "application/vnd.android.package-archive");
    context.startActivity(inten);/* www. ja v a 2s . c  o m*/
}

From source file:Main.java

public static void instanll(File file, Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    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  w w w .  ja v a  2 s .c om
}

From source file:Main.java

public static void installApk(Context context, String apkUrl) {
    File file = new File(apkUrl);
    if (!file.exists())
        return;/* w  ww. j av a  2s .c  om*/
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse(apkUrl), type);
    context.startActivity(intent);
}