本文整理匯總了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();
}
示例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();
}
示例3: removeExpiredCookies
import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void removeExpiredCookies() {
CookieManager mCookieManager = null;
if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
mCookieManager.removeExpiredCookie();
toSyncCookies();
}
}
示例4: removeExpiredCookies
import android.webkit.CookieManager; //導入方法依賴的package包/類
/**
* 清除過期的cookie
*/
public static void removeExpiredCookies() {
CookieManager mCookieManager = null;
if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
mCookieManager.removeExpiredCookie();
toSyncCookies();
}
}