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 goToMiuiPermissionActivity_V6(Context context) {
    Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
    intent.setClassName("com.miui.securitycenter",
            "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
    intent.putExtra("extra_pkgname", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);//w w  w.  j a  v  a 2s . c o  m
    } else {
        Log.e(TAG, "Intent is not available!");
    }
}

From source file:Main.java

/**
 * Open banking App for given context and secure token. Use this method if you do not use the Pay by Bank app Popup API (which takes care of the banking app
 * opening).//  www.ja v a 2s  .c  om
 *
 * @param context     The (activity or application) context to start the banking App.
 * @param secureToken The secure token of the payment for which the banking App is to be started.
 * @see #isCFIAppAvailable(Context)
 * @see #showPBBAPopup(FragmentActivity, String, String, PBBAPopupCallback)
 * @see #showPBBAErrorPopup(FragmentActivity, String, String, String, PBBAPopupCallback)
 */
public static void openBankingApp(@NonNull Context context, @NonNull final String secureToken) {

    //noinspection ConstantConditions
    if (context == null) {
        throw new IllegalArgumentException("context == null");
    }

    if (TextUtils.isEmpty(secureToken)) {
        throw new IllegalArgumentException("secureToken is required");
    }

    final Uri zappUri = Uri.parse(String.format(ZAPP_URI_FORMAT_STRING, ZAPP_SCHEME, secureToken));
    final Intent bankingAppStartIntent = new Intent(Intent.ACTION_VIEW, zappUri);
    @SuppressWarnings("BooleanVariableAlwaysNegated")
    final boolean isActivityContext = context instanceof Activity;
    if (!isActivityContext) {
        bankingAppStartIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }
    context.startActivity(bankingAppStartIntent);
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

private static void callMayDeepLink(WebView webView, Uri uri) {
    boolean mayDeepLink;
    String cb = uri.getQueryParameter("cb");
    String urlParam = uri.getQueryParameter("url");

    if ((webView.getContext() == null) || (webView.getContext().getPackageManager() == null)
            || (urlParam == null)) {/*from  w  w w . j av a2  s .com*/
        mayDeepLink = false;
    } else {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam)));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mayDeepLink = intent.resolveActivity(webView.getContext().getPackageManager()) != null;
    }

    LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>();
    list.add(new BasicNameValuePair(KEY_CALLER, CALL_MAYDEEPLINK));
    list.add(new BasicNameValuePair("mayDeepLink", String.valueOf(mayDeepLink)));
    loadResult(webView, cb, list);
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

private static void callDeepLink(WebView webView, Uri uri) {
    String cb = uri.getQueryParameter("cb");
    String urlParam = uri.getQueryParameter("url");

    LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>();
    list.add(new BasicNameValuePair(KEY_CALLER, CALL_DEEPLINK));

    if ((webView.getContext() == null) || (urlParam == null)) {
        loadResult(webView, cb, list);// w  w  w . j  a  va 2s  .co m
        return;
    }
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam)));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        webView.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        loadResult(webView, cb, list);
    }
}

From source file:com.dimasdanz.kendalipintu.NFCOpenDoorActivity.java

public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent,
            0);/*from w w  w. java 2 s  .  c o  m*/

    IntentFilter[] filters = new IntentFilter[1];
    String[][] techList = new String[][] {};
    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);
    try {
        filters[0].addDataType(MIME_TEXT_PLAIN);
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("Check your mime type.");
    }
    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}

From source file:Main.java

public static void sendScheme(Context context, String url, Bundle bundle, boolean clearTop, int flag) {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);//  w  w  w  .  j a  v a  2s.c o m
    }

    if (clearTop) {
        intent.addFlags(67108864);
    }

    if (flag != 0) {
        intent.setFlags(flag);
    }

    context.startActivity(intent);
}

From source file:Main.java

@SuppressLint("NewApi")
public static void sendScheme(Fragment context, String url, Bundle bundle, boolean clearTop, int flag) {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);/*from   w  ww  .  ja  va 2 s.c  o  m*/
    }

    if (clearTop) {
        intent.addFlags(67108864);
    }

    if (flag != 0) {
        intent.setFlags(flag);
    }

    context.startActivity(intent);
}

From source file:Main.java

public static void installApk(Context context, File file) {

    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setType("application/vnd.android.package-archive");
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*w w w. j a  v a 2 s .  com*/

}

From source file:com.kku.apps.pricesearch.util.Utils.java

public static void goHome(Context context) {
    final Intent intent = new Intent(context, HomeActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*w ww.j  a  va2  s  .c  o m*/
    ((Activity) context).overridePendingTransition(R.anim.fade, R.anim.hold);
}

From source file:im.delight.android.baselib.Social.java

/**
 * Constructs an Intent for sharing/sending a file and starts Activity chooser for that Intent
 *
 * @param context Context reference to start the Activity chooser from
 * @param windowTitle the string to be used as the window title for the Activity chooser
 * @param file the File instance to be shared
 * @param mimeType the MIME type for the file to be shared (e.g. image/jpeg)
 * @param messageTitle the message title/subject that may be provided in addition to the file, if supported by the target app
 *///from  w w w.j  a va 2  s . co  m
public static void shareFile(Context context, String windowTitle, File file, final String mimeType,
        String messageTitle) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(mimeType);
    intent.putExtra(Intent.EXTRA_SUBJECT, messageTitle);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    context.startActivity(Intent.createChooser(intent, windowTitle));
}