java.lang.Object | |
↳ | com.tencent.smtt.sdk.CookieManager |
Manages the cookies used by an application's WebView
instances.
Cookies are manipulated according to RFC2109.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
acceptCookie()
Gets whether the application's
WebView instances send and accept
cookies. | ||||||||||
synchronized boolean |
acceptThirdPartyCookies(WebView w)
Gets whether the
WebView should allow third party cookies to be set. | ||||||||||
void |
flush()
Ensures all cookies currently accessible through the getCookie API are
written to persistent storage.
| ||||||||||
String |
getCookie(String url)
Gets the cookies for the given URL.
| ||||||||||
static CookieManager |
getInstance()
Gets the singleton CookieManager instance.
| ||||||||||
boolean |
hasCookies()
Gets whether there are stored cookies.
| ||||||||||
void |
removeAllCookies(ValueCallback<Boolean> callback)
Removes all cookies.
| ||||||||||
void |
removeSessionCookies(ValueCallback<Boolean> callback)
Removes all session cookies, which are cookies without an expiration
date.
| ||||||||||
synchronized void |
setAcceptCookie(boolean accept)
Sets whether the application's
WebView instances should send and
accept cookies. | ||||||||||
synchronized void |
setAcceptThirdPartyCookies(WebView w, boolean accept)
Sets whether the
WebView should allow third party cookies to be set. | ||||||||||
synchronized void |
setCookie(String url, String value, boolean forceSet)
Sets a cookie for the given URL.
| ||||||||||
synchronized void |
setCookie(String url, String value, ValueCallback<Boolean> callback)
Sets a cookie for the given URL.
| ||||||||||
synchronized void |
setCookie(String url, String value)
Sets a cookie for the given URL.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Ensures all cookies currently accessible through the getCookie API are written to persistent storage. This call will block the caller until it is done and may perform I/O.
Gets the cookies for the given URL.
url | the URL for which the cookies are requested |
---|
Gets the singleton CookieManager instance.
Gets whether there are stored cookies.
true
if there are stored cookies
Removes all cookies.
This method is asynchronous.
If a ValueCallback
is provided,
onReceiveValue()
will be called on the current
thread's android.os.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, and in this case it is safe to call the
method from a thread without a Looper.
callback | a callback which is executed when the cookies have been removed |
---|
Removes all session cookies, which are cookies without an expiration date.
This method is asynchronous.
If a ValueCallback
is provided,
onReceiveValue()
will be called on the current
thread's android.os.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 cookie were removed, and in this case it is safe to call the
method from a thread without a Looper.
callback | a callback which is executed when the session cookies have been removed |
---|
Sets whether the application's WebView
instances should send and
accept cookies.
By default this is set to true
and the WebView accepts cookies.
When this is true
setAcceptThirdPartyCookies(WebView, boolean)
setAcceptThirdPartyCookies
can be used to control the policy for those specific types of cookie.
accept | whether WebView instances should send and accept
cookies
|
---|
Sets whether the WebView
should allow third party cookies to be set.
Allowing third party cookies is a per WebView policy and can be set
differently on different WebView instances.
Apps that target android.os.Build.VERSION_CODES#KITKAT or below default to allowing third party cookies. Apps targeting android.os.Build.VERSION_CODES#LOLLIPOP or later default to disallowing third party cookies.
Sets a cookie for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
url | the URL for which the cookie is to be set |
---|---|
value | the cookie as a string, using the format of the 'Set-Cookie' HTTP response header |
forceSet | true write immediately, otherwise not |
Sets a cookie for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
This method is asynchronous.
If a ValueCallback
is provided,
onReceiveValue(Object)
will be called on the current
thread's android.os.Looper once the operation is complete.
The value provided to the callback indicates whether the cookie was set successfully.
You can pass null
as the callback if you don't need to know when the operation
completes or whether it succeeded, and in this case it is safe to call the method from a
thread without a Looper.
url | the URL for which the cookie is to be set |
---|---|
value | the cookie as a string, using the format of the 'Set-Cookie' HTTP response header |
callback | a callback to be executed when the cookie has been set |
Sets a cookie for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
url | the URL for which the cookie is to be set |
---|---|
value | the cookie as a string, using the format of the 'Set-Cookie' HTTP response header |