从文档:
If a ValueCallback is provided, onReceiveValue() will be called on the current thread’s Looper once the operation is complete. The value provided to the callback indicates whether any cookies were removed. You can pass null as the callback if you don’t need to know when the operation completes or whether any cookies were removed
所以你可以做到这一点
CookieManager.getInstance().removeAllCookies(new ValueCallback() {
@Override
public void onReceiveValue(Boolean value) {
Log.d(TAG, "onReceiveValue " + value);
}
});
要么
CookieManager.getInstance().removeAllCookies(null);
此方法在API级别21中引入.如果您支持旧版本,则可能必须提供类似的内容.
if(API Level >= 21){
CookieManager.getInstance().removeAllCookies(null);
}else{
CookieManager.getInstance().removeAllCookie();
}