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


Java CookieManager.removeExpiredCookie方法代碼示例

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


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

示例1: clearCookiesForDomain

import android.webkit.CookieManager; //導入方法依賴的package包/類
private static void clearCookiesForDomain(Context context, String domain) {
    // This is to work around a bug where CookieManager may fail to instantiate if CookieSyncManager
    // has never been created.
    CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
    syncManager.sync();

    CookieManager cookieManager = CookieManager.getInstance();

    String cookies = cookieManager.getCookie(domain);
    if (cookies == null) {
        return;
    }

    String[] splitCookies = cookies.split(";");
    for (String cookie : splitCookies) {
        String[] cookieParts = cookie.split("=");
        if (cookieParts.length > 0) {
            String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
            cookieManager.setCookie(domain, newCookie);
        }
    }
    cookieManager.removeExpiredCookie();
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:Utility.java

示例2: clearCookiesForDomain

import android.webkit.CookieManager; //導入方法依賴的package包/類
private static void clearCookiesForDomain(Context context, String domain) {
    // This is to work around a bug where CookieManager may fail to instantiate if
    // CookieSyncManager has never been created.
    CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
    syncManager.sync();

    CookieManager cookieManager = CookieManager.getInstance();

    String cookies = cookieManager.getCookie(domain);
    if (cookies == null) {
        return;
    }

    String[] splitCookies = cookies.split(";");
    for (String cookie : splitCookies) {
        String[] cookieParts = cookie.split("=");
        if (cookieParts.length > 0) {
            String newCookie = cookieParts[0].trim() +
                    "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
            cookieManager.setCookie(domain, newCookie);
        }
    }
    cookieManager.removeExpiredCookie();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:25,代碼來源:Utility.java

示例3: removeExpiredCookies

import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void removeExpiredCookies() {
    CookieManager mCookieManager = null;
    if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
        mCookieManager.removeExpiredCookie();
        toSyncCookies();
    }
}
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:8,代碼來源:AgentWebConfig.java

示例4: removeExpiredCookies

import android.webkit.CookieManager; //導入方法依賴的package包/類
/**
 * 清除過期的cookie
 */
public static void removeExpiredCookies() {
    CookieManager mCookieManager = null;
    if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
        mCookieManager.removeExpiredCookie();
        toSyncCookies();
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:11,代碼來源:CookiesHandler.java


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