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 enableAccess(Context context) {
    Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*  w  w  w  .j ava  2s  .c  o  m*/
}

From source file:Main.java

/**
 * <pre>/* w w  w.j  a  va  2 s. c om*/
 * Open other app to view URL of an app (typically browser or Google Play)
 * </pre>
 * @param downloadUrl
 */
public static void openDownloadPage(String downloadUrl) {
    Context context = getCurrentContext();
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse(downloadUrl));
    context.startActivity(intent);
}

From source file:Main.java

public static void uninstallApp(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);/*from w w w.  j a v  a2  s .  c o m*/
}

From source file:Main.java

public static void call(Context context, String tel) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + tel));
    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 uninstallSoftware(Context context, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(uninstallIntent);
}

From source file:Main.java

public static void uninstallApk(Context ctx, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ctx.startActivity(uninstallIntent);//from w w  w. j a  v  a2s. c o m
}

From source file:Main.java

public static void putData(Context context, Class<?> activity, String key, String value) {
    Intent intent = new Intent();
    intent.setClass(context, activity);/*from w w w .  j  av  a2s .  c o  m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra(key, value);
    context.startActivity(intent);
}

From source file:Main.java

public static void startUnistalledApp(Context mContext, String pkgName) {
    Uri packageUri = Uri.parse("package:" + pkgName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
    uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(uninstallIntent);

}

From source file:Main.java

public static void openApplication(final Context context, String packageName) {
    PackageManager packageManager = context.getPackageManager();
    Intent intent = packageManager.getLaunchIntentForPackage(packageName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*  w w  w  .  ja  v  a  2 s .  c  o  m*/
}

From source file:Main.java

public static void callPhone(Context context, String phoneNum) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNum));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// w ww  .j a  v  a  2 s  . co  m
}