當前位置: 首頁>>代碼示例>>Java>>正文


Java CookieManager.flush方法代碼示例

本文整理匯總了Java中android.webkit.CookieManager.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieManager.flush方法的具體用法?Java CookieManager.flush怎麽用?Java CookieManager.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.CookieManager的用法示例。


在下文中一共展示了CookieManager.flush方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeApp

import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void closeApp (final Activity activity, WebView webView) {

        sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
        sharedPref.edit().putString("started", "").apply();
        sharedPref.edit().putInt("closeApp", 1).apply();

        if (sharedPref.getBoolean ("clearCookies", false)){
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.removeAllCookies(null);
            cookieManager.flush();
        }

        if (sharedPref.getBoolean ("clearCache", false)){
            webView.clearCache(true);
        }

        if (sharedPref.getBoolean ("clearForm", false)){
            webView.clearFormData();
        }

        if (sharedPref.getBoolean ("history", false)){
            activity.deleteDatabase("history_DB_v01.db");
            webView.clearHistory();
        }

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                activity.finish();
            }
        }, 500);
    }
 
開發者ID:JaeNuguid,項目名稱:Kids-Portal-Android,代碼行數:34,代碼來源:helper_main.java

示例2: clearCookieByUrlInternal

import android.webkit.CookieManager; //導入方法依賴的package包/類
private static void clearCookieByUrlInternal(String url, CookieManager pCookieManager) {
    if (TextUtils.isEmpty(url)) {
        return;
    }
    String cookieString = pCookieManager.getCookie(url);
    Vector<String> cookie = getCookieNamesByUrl(cookieString);
    if (cookie == null || cookie.isEmpty()) {
        return;
    }
    int len = cookie.size();
    for (int i = 0; i < len; i++) {
        pCookieManager.setCookie(url, cookie.get(i) + "=-1");
    }
    pCookieManager.flush();
}
 
開發者ID:JaeNuguid,項目名稱:Kids-Portal-Android,代碼行數:16,代碼來源:Utils_UserAgent.java

示例3: httpCookieSync

import android.webkit.CookieManager; //導入方法依賴的package包/類
/**
 * Synchronize the uuid2 cookie to the Webview Cookie Jar
 * This is only done if there is no present cookie.
 *
 * @param headers headers to extract cookies from for syncing
 */
@SuppressWarnings("deprecation")
private void httpCookieSync(Map<String, List<String>> headers) {
    if (headers == null || headers.isEmpty()) return;
    CookieManager cm = CookieManager.getInstance();
    if (cm == null) {
        LogUtil.i(Settings.TAG, "Unable to find a CookieManager");
        return;
    }
    try {
        String existingUUID = getExistingCookie();

        for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
            String key = entry.getKey();
            // Only "Set-cookie" and "Set-cookie2" pair will be parsed
            if (key != null && (key.equalsIgnoreCase(Settings.VERSION_ZERO_HEADER)
                    || key.equalsIgnoreCase(Settings.VERSION_ONE_HEADER))) {
                for (String cookieStr : entry.getValue()) {
                    if (!TextUtils.isEmpty(cookieStr) && cookieStr.contains(Settings.AN_UUID)) {
                        // pass uuid2 to WebView Cookie jar if it's empty or outdated
                        if (existingUUID == null || !cookieStr.contains(existingUUID)) {
                            cm.setCookie(Settings.COOKIE_DOMAIN, cookieStr);
                            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                                // CookieSyncManager is deprecated in API 21 Lollipop
                                CookieSyncManager.createInstance(context);
                                CookieSyncManager csm = CookieSyncManager.getInstance();
                                if (csm == null) {
                                    LogUtil.i(Settings.TAG, "Unable to find a CookieSyncManager");
                                    return;
                                }
                                csm.sync();
                            } else {
                                cm.flush();
                            }
                        }
                    }
                }
            }
        }
    } catch (IllegalStateException ise) {
    } catch (Exception e) {
    }
}
 
開發者ID:prebid,項目名稱:prebid-mobile-android,代碼行數:49,代碼來源:ServerConnector.java


注:本文中的android.webkit.CookieManager.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。