当前位置: 首页>>代码示例>>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;未经允许,请勿转载。