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 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);/*  ww w.ja v a2s  .c o m*/
}

From source file:Main.java

public static void openSendMsg(Context getContext) {
    Uri uri = Uri.parse("smsto:");
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getContext.startActivity(intent);//from ww w. ja va  2 s .  c  om
}

From source file:Main.java

@SuppressLint("NewApi")
public static void doSettings(Context context) {
    Intent intent = new Intent(Settings.ACTION_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*  www .  ja va 2  s  . com*/
}

From source file:Main.java

public static void openSendMsg(Context context) {
    Uri uri = Uri.parse("smsto:");
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.setFlags(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 startActivity(Activity callingActivity, Class<?> targetActivity) {
    Intent intent = new Intent(callingActivity, targetActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    callingActivity.startActivity(intent);
}

From source file:Main.java

public static void imitateHome(Context context) {
    try {/* www  .  j  a  va2 s.  c o m*/
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        context.startActivity(intent);
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:Main.java

private static void checkContextIsActivity(Context a, Intent intent) {
    if (!(a instanceof Activity)) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }/*from   w ww.  ja v a 2 s  . c  o m*/
}

From source file:Main.java

public static void launchApp(Context context, String packageName) {
    PackageManager pm = context.getPackageManager();
    Intent intent = pm.getLaunchIntentForPackage(packageName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from   w  ww  .  j av  a 2  s .  c  o  m*/
}

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;//from  w  w w.  j av  a 2s  . c om
}

From source file:Main.java

public static void installSoftwareByAPK(Context context, String filePath) {
    Uri uri = Uri.fromFile(new File(filePath));
    Intent installIntent = new Intent(Intent.ACTION_VIEW);
    installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
    context.startActivity(installIntent);
}