java.lang.Object | |
↳ | android.webkit.CookieManager |
Manages the cookies used by an application's WebView
instances.
Cookies are manipulated according to RFC2109.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets whether the application's
WebView instances send and accept
cookies.
| |||||||||||
Gets whether the
WebView should allow third party cookies to be set.
| |||||||||||
Gets whether the application's
WebView instances send and accept
cookies for file scheme URLs.
| |||||||||||
Ensures all cookies currently accessible through the getCookie API are
written to persistent storage.
| |||||||||||
Gets the cookies for the given URL.
| |||||||||||
Gets the singleton CookieManager instance.
| |||||||||||
Gets whether there are stored cookies.
| |||||||||||
This method was deprecated
in API level 21.
Use
removeAllCookies(ValueCallback) instead.
| |||||||||||
Removes all cookies.
| |||||||||||
This method was deprecated
in API level 21.
The WebView handles removing expired cookies automatically.
| |||||||||||
This method was deprecated
in API level 21.
use
removeSessionCookies(ValueCallback) instead.
| |||||||||||
Removes all session cookies, which are cookies without an expiration
date.
| |||||||||||
Sets whether the application's
WebView instances should send and
accept cookies.
| |||||||||||
Sets whether the application's
WebView instances should send and
accept cookies for file scheme URLs.
| |||||||||||
Sets whether the
WebView should allow third party cookies to be set.
| |||||||||||
Sets a cookie for the given URL.
| |||||||||||
Sets a cookie for the given URL.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates and returns a copy of this
Object .
|
[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. If this method is used
before the application instantiates a WebView
instance,
CookieSyncManager.createInstance(Context)
must be called first.
Gets whether there are stored cookies.
This method was deprecated
in API level 21.
Use removeAllCookies(ValueCallback)
instead.
Removes all cookies.
Removes all cookies.
This method is asynchronous.
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, 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 |
---|
This method was deprecated
in API level 21.
The WebView handles removing expired cookies automatically.
Removes all expired cookies.
This method was deprecated
in API level 21.
use removeSessionCookies(ValueCallback)
instead.
Removes all session cookies, which are cookies without an expiration date.
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 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
and
setAcceptFileSchemeCookies
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 application's WebView
instances should send and
accept cookies for file scheme URLs.
Use of cookies with file scheme URLs is potentially insecure and turned
off by default.
Do not use this feature unless you can be sure that no unintentional
sharing of cookie data can take place.
Note that calls to this method will have no effect if made after a
WebView
or CookieManager instance has been created.
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 KITKAT
or below
default to allowing third party cookies. Apps targeting
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.
This method is asynchronous.
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 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 |
Creates and returns a copy of this Object
. The default
implementation returns a so-called "shallow" copy: It creates a new
instance of the same class and then copies the field values (including
object references) from this instance to the new instance. A "deep" copy,
in contrast, would also recursively clone nested objects. A subclass that
needs to implement this kind of cloning should call super.clone()
to create the new instance and then create deep copies of the nested,
mutable objects.
CloneNotSupportedException |
---|