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 openSettings(Context context) {
    Intent intent = new Intent(Settings.ACTION_SETTINGS); // Settings.ACTION_WIFI_SETTINGS
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from ww w.  j a v a2  s.  c  o  m*/
}

From source file:Main.java

public static void openLink(Context context, String url) {
    if (url.equals("")) {
        return;/* w ww . j  av  a  2s  . c  om*/
    }
    ;

    if (!url.startsWith("http://") && !url.startsWith("https://"))
        url = "http://" + url;

    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(browserIntent);
}

From source file:Main.java

public static void gotoActivity(Context ctx, Class<?> c, String s, boolean b, int flag) {
    Intent intent = new Intent(ctx, c);
    intent.putExtra(s, b);//from   w w  w  . j  a  v a 2s  .c  om
    intent.setFlags(flag);
    ctx.startActivity(intent);
    ((Activity) ctx).finish();
}

From source file:Main.java

public static void startMarket(Context context, String packageName, String referrer) {
    String referrerParam = referrer != null ? "&referrer=" + referrer : "";
    try {/*from w w  w .  j  av  a  2 s.c  o  m*/
        Uri uri = Uri.parse("market://details?id=" + packageName + referrerParam);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (ActivityNotFoundException anfe) {
        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + referrerParam));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
}

From source file:Main.java

public static void startActivityNoHistory(Activity activity, Class classActivity) {
    Intent intent = new Intent();
    intent.setClass(activity, classActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(intent);//from ww w .  j av a  2  s.  c  o m
}

From source file:Main.java

public static void start(Context paramContext, String paramString) {
    Uri localUri = Uri.parse(paramString);
    Intent localIntent = new Intent("android.intent.action.VIEW", localUri);
    localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    paramContext.startActivity(localIntent);
}

From source file:com.manning.androidhacks.hack046.helper.NotificationHelper.java

private static PendingIntent getPendingIntent(Context ctx) {
    Intent intent = new Intent(ctx, MsgActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return PendingIntent.getActivity(ctx, 0, intent, 0);
}

From source file:Main.java

public static void doCall(Activity aty, String mobile) throws Exception {
    if (null != aty && null != mobile) {
        Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + mobile));
        phoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        aty.startActivity(phoneIntent);//from w  ww . ja v  a  2 s . c o  m
    }
}

From source file:Main.java

public static void sendSms(Context context, String phoneNum, String content) {
    Intent mIntent = new Intent(Intent.ACTION_VIEW);
    mIntent.putExtra("address", phoneNum);
    mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mIntent.putExtra("sms_body", content);
    mIntent.setType("vnd.android-dir/mms-sms");
    context.startActivity(mIntent);//from www . jav a  2s  .  co m
}

From source file:Main.java

public static void sendEmail(Context context, String receiver, String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { receiver });
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    try {/*from   w  ww.  ja v  a 2  s.  c o m*/
        context.startActivity(Intent.createChooser(intent, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
    }
}