WebSettings
public
abstract
class
WebSettings
extends Object
java.lang.Object | |
↳ | android.webkit.WebSettings |
Manages settings state for a WebView. When a WebView is first created, it
obtains a set of default settings. These default settings will be returned
from any getter call. A WebSettings
object obtained from
WebView.getSettings()
is tied to the life of the WebView. If a WebView has
been destroyed, any method call on WebSettings
will throw an
IllegalStateException
.
Summary
Nested classes | |
---|---|
enum |
WebSettings.LayoutAlgorithm
Enum for controlling the layout of html. |
enum |
WebSettings.PluginState
The plugin state effects how plugins are treated on a page. |
enum |
WebSettings.RenderPriority
|
enum |
WebSettings.TextSize
This enum was deprecated
in API level 14.
Use |
enum |
WebSettings.ZoomDensity
Enum for specifying the WebView's desired density. |
Constants | |
---|---|
int |
LOAD_CACHE_ELSE_NETWORK
Use cached resources when they are available, even if they have expired. |
int |
LOAD_CACHE_ONLY
Don't use the network, load from the cache. |
int |
LOAD_DEFAULT
Default cache usage mode. |
int |
LOAD_NORMAL
This constant was deprecated
in API level 17.
This value is obsolete, as from API level
|
int |
LOAD_NO_CACHE
Don't use the cache, load from the network. |
int |
MENU_ITEM_NONE
Used with |
int |
MENU_ITEM_PROCESS_TEXT
Used with |
int |
MENU_ITEM_SHARE
Used with |
int |
MENU_ITEM_WEB_SEARCH
Used with |
int |
MIXED_CONTENT_ALWAYS_ALLOW
Used with |
int |
MIXED_CONTENT_COMPATIBILITY_MODE
Used with |
int |
MIXED_CONTENT_NEVER_ALLOW
Used with |
Public constructors | |
---|---|
WebSettings()
|
Public methods | |
---|---|
abstract
boolean
|
enableSmoothTransition()
This method was deprecated in API level 17. This method is now obsolete, and will become a no-op in future. |
abstract
boolean
|
getAllowContentAccess()
Gets whether this WebView supports content URL access. |
abstract
boolean
|
getAllowFileAccess()
Gets whether this WebView supports file access. |
abstract
boolean
|
getAllowFileAccessFromFileURLs()
Gets whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs. |
abstract
boolean
|
getAllowUniversalAccessFromFileURLs()
Gets whether JavaScript running in the context of a file scheme URL can access content from any origin. |
abstract
boolean
|
getBlockNetworkImage()
Gets whether the WebView does not load image resources from the network. |
abstract
boolean
|
getBlockNetworkLoads()
Gets whether the WebView does not load any resources from the network. |
abstract
boolean
|
getBuiltInZoomControls()
Gets whether the zoom mechanisms built into WebView are being used. |
abstract
int
|
getCacheMode()
Gets the current setting for overriding the cache mode. |
abstract
String
|
getCursiveFontFamily()
Gets the cursive font family name. |
abstract
boolean
|
getDatabaseEnabled()
Gets whether the database storage API is enabled. |
abstract
String
|
getDatabasePath()
This method was deprecated in API level 19. Database paths are managed by the implementation this method is obsolete. |
abstract
int
|
getDefaultFixedFontSize()
Gets the default fixed font size. |
abstract
int
|
getDefaultFontSize()
Gets the default font size. |
abstract
String
|
getDefaultTextEncodingName()
Gets the default text encoding name. |
static
String
|
getDefaultUserAgent(Context context)
Returns the default User-Agent used by a WebView. |
abstract
WebSettings.ZoomDensity
|
getDefaultZoom()
This method was deprecated in API level 19. Will only return the default value. |
abstract
int
|
getDisabledActionModeMenuItems()
Gets the action mode menu items that are disabled, expressed in an integer field flag. |
abstract
boolean
|
getDisplayZoomControls()
Gets whether the WebView displays on-screen zoom controls when using the built-in zoom mechanisms. |
abstract
boolean
|
getDomStorageEnabled()
Gets whether the DOM Storage APIs are enabled. |
abstract
String
|
getFantasyFontFamily()
Gets the fantasy font family name. |
abstract
String
|
getFixedFontFamily()
Gets the fixed font family name. |
abstract
boolean
|
getJavaScriptCanOpenWindowsAutomatically()
Gets whether JavaScript can open windows automatically. |
abstract
boolean
|
getJavaScriptEnabled()
Gets whether JavaScript is enabled. |
abstract
WebSettings.LayoutAlgorithm
|
getLayoutAlgorithm()
Gets the current layout algorithm. |
abstract
boolean
|
getLightTouchEnabled()
This method was deprecated in API level 18. This setting is obsolete. |
abstract
boolean
|
getLoadWithOverviewMode()
Gets whether this WebView loads pages in overview mode. |
abstract
boolean
|
getLoadsImagesAutomatically()
Gets whether the WebView loads image resources. |
abstract
boolean
|
getMediaPlaybackRequiresUserGesture()
Gets whether the WebView requires a user gesture to play media. |
abstract
int
|
getMinimumFontSize()
Gets the minimum font size. |
abstract
int
|
getMinimumLogicalFontSize()
Gets the minimum logical font size. |
abstract
int
|
getMixedContentMode()
Gets the current behavior of the WebView with regard to loading insecure content from a secure origin. |
abstract
boolean
|
getOffscreenPreRaster()
Gets whether this WebView should raster tiles when it is offscreen but attached to a window. |
abstract
WebSettings.PluginState
|
getPluginState()
This method was deprecated
in API level 18.
Plugins are not supported in API level
|
abstract
boolean
|
getSafeBrowsingEnabled()
Gets whether Safe Browsing is enabled. |
abstract
String
|
getSansSerifFontFamily()
Gets the sans-serif font family name. |
abstract
boolean
|
getSaveFormData()
Gets whether the WebView saves form data. |
abstract
boolean
|
getSavePassword()
This method was deprecated in API level 18. Saving passwords in WebView will not be supported in future versions. |
abstract
String
|
getSerifFontFamily()
Gets the serif font family name. |
abstract
String
|
getStandardFontFamily()
Gets the standard font family name. |
WebSettings.TextSize
|
getTextSize()
This method was deprecated
in API level 14.
Use |
abstract
int
|
getTextZoom()
Gets the text zoom of the page in percent. |
abstract
boolean
|
getUseWideViewPort()
Gets whether the WebView supports the "viewport" HTML meta tag or will use a wide viewport. |
abstract
String
|
getUserAgentString()
Gets the WebView's user-agent string. |
abstract
void
|
setAllowContentAccess(boolean allow)
Enables or disables content URL access within WebView. |
abstract
void
|
setAllowFileAccess(boolean allow)
Enables or disables file access within WebView. |
abstract
void
|
setAllowFileAccessFromFileURLs(boolean flag)
Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. |
abstract
void
|
setAllowUniversalAccessFromFileURLs(boolean flag)
Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. |
abstract
void
|
setAppCacheEnabled(boolean flag)
Sets whether the Application Caches API should be enabled. |
abstract
void
|
setAppCacheMaxSize(long appCacheMaxSize)
This method was deprecated in API level 18. In future quota will be managed automatically. |
abstract
void
|
setAppCachePath(String appCachePath)
Sets the path to the Application Caches files. |
abstract
void
|
setBlockNetworkImage(boolean flag)
Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes). |
abstract
void
|
setBlockNetworkLoads(boolean flag)
Sets whether the WebView should not load resources from the network. |
abstract
void
|
setBuiltInZoomControls(boolean enabled)
Sets whether the WebView should use its built-in zoom mechanisms. |
abstract
void
|
setCacheMode(int mode)
Overrides the way the cache is used. |
abstract
void
|
setCursiveFontFamily(String font)
Sets the cursive font family name. |
abstract
void
|
setDatabaseEnabled(boolean flag)
Sets whether the database storage API is enabled. |
abstract
void
|
setDatabasePath(String databasePath)
This method was deprecated in API level 19. Database paths are managed by the implementation and calling this method will have no effect. |
abstract
void
|
setDefaultFixedFontSize(int size)
Sets the default fixed font size. |
abstract
void
|
setDefaultFontSize(int size)
Sets the default font size. |
abstract
void
|
setDefaultTextEncodingName(String encoding)
Sets the default text encoding name to use when decoding html pages. |
abstract
void
|
setDefaultZoom(WebSettings.ZoomDensity zoom)
This method was deprecated in API level 19. This method is no longer supported, see the function documentation for recommended alternatives. |
abstract
void
|
setDisabledActionModeMenuItems(int menuItems)
Disables the action mode menu items according to |
abstract
void
|
setDisplayZoomControls(boolean enabled)
Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. |
abstract
void
|
setDomStorageEnabled(boolean flag)
Sets whether the DOM storage API is enabled. |
abstract
void
|
setEnableSmoothTransition(boolean enable)
This method was deprecated in API level 17. This method is now obsolete, and will become a no-op in future. |
abstract
void
|
setFantasyFontFamily(String font)
Sets the fantasy font family name. |
abstract
void
|
setFixedFontFamily(String font)
Sets the fixed font family name. |
abstract
void
|
setGeolocationDatabasePath(String databasePath)
This method was deprecated in API level 24. Geolocation database are managed by the implementation and calling this method will have no effect. |
abstract
void
|
setGeolocationEnabled(boolean flag)
Sets whether Geolocation is enabled. |
abstract
void
|
setJavaScriptCanOpenWindowsAutomatically(boolean flag)
Tells JavaScript to open windows automatically. |
abstract
void
|
setJavaScriptEnabled(boolean flag)
Tells the WebView to enable JavaScript execution. |
abstract
void
|
setLayoutAlgorithm(WebSettings.LayoutAlgorithm l)
Sets the underlying layout algorithm. |
abstract
void
|
setLightTouchEnabled(boolean enabled)
This method was deprecated
in API level 18.
From |
abstract
void
|
setLoadWithOverviewMode(boolean overview)
Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width. |
abstract
void
|
setLoadsImagesAutomatically(boolean flag)
Sets whether the WebView should load image resources. |
abstract
void
|
setMediaPlaybackRequiresUserGesture(boolean require)
Sets whether the WebView requires a user gesture to play media. |
abstract
void
|
setMinimumFontSize(int size)
Sets the minimum font size. |
abstract
void
|
setMinimumLogicalFontSize(int size)
Sets the minimum logical font size. |
abstract
void
|
setMixedContentMode(int mode)
Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. |
abstract
void
|
setNeedInitialFocus(boolean flag)
Tells the WebView whether it needs to set a node to have focus when
|
abstract
void
|
setOffscreenPreRaster(boolean enabled)
Sets whether this WebView should raster tiles when it is offscreen but attached to a window. |
abstract
void
|
setPluginState(WebSettings.PluginState state)
This method was deprecated
in API level 18.
Plugins are not supported in API level
|
abstract
void
|
setRenderPriority(WebSettings.RenderPriority priority)
This method was deprecated in API level 18. It is not recommended to adjust thread priorities, and this will not be supported in future versions. |
abstract
void
|
setSafeBrowsingEnabled(boolean enabled)
Sets whether Safe Browsing is enabled. |
abstract
void
|
setSansSerifFontFamily(String font)
Sets the sans-serif font family name. |
abstract
void
|
setSaveFormData(boolean save)
Sets whether the WebView should save form data. |
abstract
void
|
setSavePassword(boolean save)
This method was deprecated in API level 18. Saving passwords in WebView will not be supported in future versions. |
abstract
void
|
setSerifFontFamily(String font)
Sets the serif font family name. |
abstract
void
|
setStandardFontFamily(String font)
Sets the standard font family name. |
abstract
void
|
setSupportMultipleWindows(boolean support)
Sets whether the WebView whether supports multiple windows. |
abstract
void
|
setSupportZoom(boolean support)
Sets whether the WebView should support zooming using its on-screen zoom controls and gestures. |
void
|
setTextSize(WebSettings.TextSize t)
This method was deprecated
in API level 14.
Use |
abstract
void
|
setTextZoom(int textZoom)
Sets the text zoom of the page in percent. |
abstract
void
|
setUseWideViewPort(boolean use)
Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. |
abstract
void
|
setUserAgentString(String ua)
Sets the WebView's user-agent string. |
abstract
boolean
|
supportMultipleWindows()
Gets whether the WebView supports multiple windows. |
abstract
boolean
|
supportZoom()
Gets whether the WebView supports zoom. |
Inherited methods | |
---|---|
Constants
LOAD_CACHE_ELSE_NETWORK
public static final int LOAD_CACHE_ELSE_NETWORK
Use cached resources when they are available, even if they have expired.
Otherwise load resources from the network.
Use with setCacheMode(int)
.
Constant Value: 1 (0x00000001)
LOAD_CACHE_ONLY
public static final int LOAD_CACHE_ONLY
Don't use the network, load from the cache.
Use with setCacheMode(int)
.
Constant Value: 3 (0x00000003)
LOAD_DEFAULT
public static final int LOAD_DEFAULT
Default cache usage mode. If the navigation type doesn't impose any
specific behavior, use cached resources when they are available
and not expired, otherwise load resources from the network.
Use with setCacheMode(int)
.
Constant Value: -1 (0xffffffff)
LOAD_NORMAL
public static final int LOAD_NORMAL
This constant was deprecated
in API level 17.
This value is obsolete, as from API level
Build.VERSION_CODES.HONEYCOMB
and onwards it has the
same effect as LOAD_DEFAULT
.
Normal cache usage mode. Use with setCacheMode(int)
.
Constant Value: 0 (0x00000000)
LOAD_NO_CACHE
public static final int LOAD_NO_CACHE
Don't use the cache, load from the network.
Use with setCacheMode(int)
.
Constant Value: 2 (0x00000002)
MENU_ITEM_NONE
public static final int MENU_ITEM_NONE
Used with setDisabledActionModeMenuItems(int)
.
No menu items should be disabled.
Constant Value: 0 (0x00000000)
MENU_ITEM_PROCESS_TEXT
public static final int MENU_ITEM_PROCESS_TEXT
Used with setDisabledActionModeMenuItems(int)
.
Disable all the action mode menu items for text processing.
By default WebView searches for activities that are able to handle
Intent.ACTION_PROCESS_TEXT
and show them in the
action mode menu. If this flag is set via setDisabledActionModeMenuItems(int)
, these menu items will be disabled.
Constant Value: 4 (0x00000004)
MENU_ITEM_SHARE
public static final int MENU_ITEM_SHARE
Used with setDisabledActionModeMenuItems(int)
.
Disable menu item "Share".
Constant Value: 1 (0x00000001)
MENU_ITEM_WEB_SEARCH
public static final int MENU_ITEM_WEB_SEARCH
Used with setDisabledActionModeMenuItems(int)
.
Disable menu item "Web Search".
Constant Value: 2 (0x00000002)
MIXED_CONTENT_ALWAYS_ALLOW
public static final int MIXED_CONTENT_ALWAYS_ALLOW
Used with setMixedContentMode(int)
In this mode, the WebView will allow a secure origin to load content from any other origin,
even if that origin is insecure. This is the least secure mode of operation for the WebView,
and where possible apps should not set this mode.
Constant Value: 0 (0x00000000)
MIXED_CONTENT_COMPATIBILITY_MODE
public static final int MIXED_CONTENT_COMPATIBILITY_MODE
Used with setMixedContentMode(int)
In this mode, the WebView will attempt to be compatible with the approach of a modern web
browser with regard to mixed content. Some insecure content may be allowed to be loaded by
a secure origin and other types of content will be blocked. The types of content are allowed
or blocked may change release to release and are not explicitly defined.
This mode is intended to be used by apps that are not in control of the content that they
render but desire to operate in a reasonably secure environment. For highest security, apps
are recommended to use MIXED_CONTENT_NEVER_ALLOW
.
Constant Value: 2 (0x00000002)
MIXED_CONTENT_NEVER_ALLOW
public static final int MIXED_CONTENT_NEVER_ALLOW
Used with setMixedContentMode(int)
In this mode, the WebView will not allow a secure origin to load content from an insecure
origin. This is the preferred and most secure mode of operation for the WebView and apps are
strongly advised to use this mode.
Constant Value: 1 (0x00000001)
Public constructors
Public methods
enableSmoothTransition
public abstract boolean enableSmoothTransition ()
This method was deprecated
in API level 17.
This method is now obsolete, and will become a no-op in future.
Gets whether the WebView enables smooth transition while panning or zooming.
Returns | |
---|---|
boolean |
See also:
getAllowContentAccess
public abstract boolean getAllowContentAccess ()
Gets whether this WebView supports content URL access.
Returns | |
---|---|
boolean |
See also:
getAllowFileAccess
public abstract boolean getAllowFileAccess ()
Gets whether this WebView supports file access.
Returns | |
---|---|
boolean |
See also:
getAllowFileAccessFromFileURLs
public abstract boolean getAllowFileAccessFromFileURLs ()
Gets whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs.
Returns | |
---|---|
boolean |
whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs |
See also:
getAllowUniversalAccessFromFileURLs
public abstract boolean getAllowUniversalAccessFromFileURLs ()
Gets whether JavaScript running in the context of a file scheme URL can access content from any origin. This includes access to content from other file scheme URLs.
Returns | |
---|---|
boolean |
whether JavaScript running in the context of a file scheme URL can access content from any origin |
getBlockNetworkImage
public abstract boolean getBlockNetworkImage ()
Gets whether the WebView does not load image resources from the network.
Returns | |
---|---|
boolean |
true if the WebView does not load image resources from the network |
See also:
getBlockNetworkLoads
public abstract boolean getBlockNetworkLoads ()
Gets whether the WebView does not load any resources from the network.
Returns | |
---|---|
boolean |
true if the WebView does not load any resources from the network |
See also:
getBuiltInZoomControls
public abstract boolean getBuiltInZoomControls ()
Gets whether the zoom mechanisms built into WebView are being used.
Returns | |
---|---|
boolean |
true if the zoom mechanisms built into WebView are being used |
See also:
getCacheMode
public abstract int getCacheMode ()
Gets the current setting for overriding the cache mode.
Returns | |
---|---|
int |
the current setting for overriding the cache mode Value is |
See also:
getCursiveFontFamily
public abstract String getCursiveFontFamily ()
Gets the cursive font family name.
Returns | |
---|---|
String |
the cursive font family name as a string |
See also:
getDatabaseEnabled
public abstract boolean getDatabaseEnabled ()
Gets whether the database storage API is enabled.
Returns | |
---|---|
boolean |
true if the database storage API is enabled |
See also:
getDatabasePath
public abstract String getDatabasePath ()
This method was deprecated
in API level 19.
Database paths are managed by the implementation this method is obsolete.
Gets the path to where database storage API databases are saved.
Returns | |
---|---|
String |
the String path to the database storage API databases |
See also:
getDefaultFixedFontSize
public abstract int getDefaultFixedFontSize ()
Gets the default fixed font size.
Returns | |
---|---|
int |
a non-negative integer between 1 and 72 |
See also:
getDefaultFontSize
public abstract int getDefaultFontSize ()
Gets the default font size.
Returns | |
---|---|
int |
a non-negative integer between 1 and 72 |
See also:
getDefaultTextEncodingName
public abstract String getDefaultTextEncodingName ()
Gets the default text encoding name.
Returns | |
---|---|
String |
the default text encoding name as a string |
See also:
getDefaultUserAgent
public static String getDefaultUserAgent (Context context)
Returns the default User-Agent used by a WebView.
An instance of WebView could use a different User-Agent if a call
is made to setUserAgentString(String)
.
Parameters | |
---|---|
context |
Context : a Context object used to access application assets
|
Returns | |
---|---|
String |
getDefaultZoom
public abstract WebSettings.ZoomDensity getDefaultZoom ()
This method was deprecated
in API level 19.
Will only return the default value.
Gets the default zoom density of the page. This should be called from the UI thread. This setting is not recommended for use in new applications.
Returns | |
---|---|
WebSettings.ZoomDensity |
the zoom density |
See also:
getDisabledActionModeMenuItems
public abstract int getDisabledActionModeMenuItems ()
Gets the action mode menu items that are disabled, expressed in an integer field flag.
The default value is MENU_ITEM_NONE
Returns | |
---|---|
int |
all the disabled menu item flags combined with bitwise OR.
Value is either |
getDisplayZoomControls
public abstract boolean getDisplayZoomControls ()
Gets whether the WebView displays on-screen zoom controls when using the built-in zoom mechanisms.
Returns | |
---|---|
boolean |
true if the WebView displays on-screen zoom controls when using
the built-in zoom mechanisms |
See also:
getDomStorageEnabled
public abstract boolean getDomStorageEnabled ()
Gets whether the DOM Storage APIs are enabled.
Returns | |
---|---|
boolean |
true if the DOM Storage APIs are enabled |
See also:
getFantasyFontFamily
public abstract String getFantasyFontFamily ()
Gets the fantasy font family name.
Returns | |
---|---|
String |
the fantasy font family name as a string |
See also:
getFixedFontFamily
public abstract String getFixedFontFamily ()
Gets the fixed font family name.
Returns | |
---|---|
String |
the fixed font family name as a string |
See also:
getJavaScriptCanOpenWindowsAutomatically
public abstract boolean getJavaScriptCanOpenWindowsAutomatically ()
Gets whether JavaScript can open windows automatically.
Returns | |
---|---|
boolean |
true if JavaScript can open windows automatically during
window.open() |
getJavaScriptEnabled
public abstract boolean getJavaScriptEnabled ()
Gets whether JavaScript is enabled.
Returns | |
---|---|
boolean |
true if JavaScript is enabled |
See also:
getLayoutAlgorithm
public abstract WebSettings.LayoutAlgorithm getLayoutAlgorithm ()
Gets the current layout algorithm.
Returns | |
---|---|
WebSettings.LayoutAlgorithm |
the layout algorithm in use, as a WebSettings.LayoutAlgorithm value |
getLightTouchEnabled
public abstract boolean getLightTouchEnabled ()
This method was deprecated
in API level 18.
This setting is obsolete.
Gets whether light touches are enabled.
Returns | |
---|---|
boolean |
See also:
getLoadWithOverviewMode
public abstract boolean getLoadWithOverviewMode ()
Gets whether this WebView loads pages in overview mode.
Returns | |
---|---|
boolean |
whether this WebView loads pages in overview mode |
See also:
getLoadsImagesAutomatically
public abstract boolean getLoadsImagesAutomatically ()
Gets whether the WebView loads image resources. This includes images embedded using the data URI scheme.
Returns | |
---|---|
boolean |
true if the WebView loads image resources |
See also:
getMediaPlaybackRequiresUserGesture
public abstract boolean getMediaPlaybackRequiresUserGesture ()
Gets whether the WebView requires a user gesture to play media.
Returns | |
---|---|
boolean |
true if the WebView requires a user gesture to play media |
getMinimumFontSize
public abstract int getMinimumFontSize ()
Gets the minimum font size.
Returns | |
---|---|
int |
a non-negative integer between 1 and 72 |
See also:
getMinimumLogicalFontSize
public abstract int getMinimumLogicalFontSize ()
Gets the minimum logical font size.
Returns | |
---|---|
int |
a non-negative integer between 1 and 72 |
See also:
getMixedContentMode
public abstract int getMixedContentMode ()
Gets the current behavior of the WebView with regard to loading insecure content from a secure origin.
Returns | |
---|---|
int |
The current setting, one of MIXED_CONTENT_NEVER_ALLOW ,
MIXED_CONTENT_ALWAYS_ALLOW or MIXED_CONTENT_COMPATIBILITY_MODE .
|
getOffscreenPreRaster
public abstract boolean getOffscreenPreRaster ()
Gets whether this WebView should raster tiles when it is offscreen but attached to a window.
Returns | |
---|---|
boolean |
true if this WebView will raster tiles when it is
offscreen but attached to a window.
|
getPluginState
public abstract WebSettings.PluginState getPluginState ()
This method was deprecated
in API level 18.
Plugins are not supported in API level
Build.VERSION_CODES.KITKAT
or later;
enabling plugins is a no-op.
Gets the current state regarding whether plugins are enabled.
Returns | |
---|---|
WebSettings.PluginState |
the plugin state as a WebSettings.PluginState value |
See also:
getSafeBrowsingEnabled
public abstract boolean getSafeBrowsingEnabled ()
Gets whether Safe Browsing is enabled.
See setSafeBrowsingEnabled(boolean)
.
Returns | |
---|---|
boolean |
true if Safe Browsing is enabled and false otherwise.
|
getSansSerifFontFamily
public abstract String getSansSerifFontFamily ()
Gets the sans-serif font family name.
Returns | |
---|---|
String |
the sans-serif font family name as a string |
See also:
getSaveFormData
public abstract boolean getSaveFormData ()
Gets whether the WebView saves form data.
Returns | |
---|---|
boolean |
whether the WebView saves form data |
See also:
getSavePassword
public abstract boolean getSavePassword ()
This method was deprecated
in API level 18.
Saving passwords in WebView will not be supported in future versions.
Gets whether the WebView saves passwords.
Returns | |
---|---|
boolean |
whether the WebView saves passwords |
See also:
getSerifFontFamily
public abstract String getSerifFontFamily ()
Gets the serif font family name. The default is "serif".
Returns | |
---|---|
String |
the serif font family name as a string |
See also:
getStandardFontFamily
public abstract String getStandardFontFamily ()
Gets the standard font family name.
Returns | |
---|---|
String |
the standard font family name as a string |
See also:
getTextSize
public WebSettings.TextSize getTextSize ()
This method was deprecated
in API level 14.
Use getTextZoom()
instead.
Gets the text size of the page. If the text size was previously specified
in percent using setTextZoom(int)
, this will return the closest
matching WebSettings.TextSize
.
Returns | |
---|---|
WebSettings.TextSize |
the text size as a WebSettings.TextSize value |
See also:
getTextZoom
public abstract int getTextZoom ()
Gets the text zoom of the page in percent.
Returns | |
---|---|
int |
the text zoom of the page in percent |
See also:
getUseWideViewPort
public abstract boolean getUseWideViewPort ()
Gets whether the WebView supports the "viewport" HTML meta tag or will use a wide viewport.
Returns | |
---|---|
boolean |
true if the WebView supports the viewport meta tag |
See also:
getUserAgentString
public abstract String getUserAgentString ()
Gets the WebView's user-agent string.
Returns | |
---|---|
String |
the WebView's user-agent string |
See also:
setAllowContentAccess
public abstract void setAllowContentAccess (boolean allow)
Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default is enabled.
Parameters | |
---|---|
allow |
boolean |
setAllowFileAccess
public abstract void setAllowFileAccess (boolean allow)
Enables or disables file access within WebView. File access is enabled by default. Note that this enables or disables file system access only. Assets and resources are still accessible using file:///android_asset and file:///android_res.
Parameters | |
---|---|
allow |
boolean |
setAllowFileAccessFromFileURLs
public abstract void setAllowFileAccessFromFileURLs (boolean flag)
Sets whether JavaScript running in the context of a file scheme URL
should be allowed to access content from other file scheme URLs. To
enable the most restrictive, and therefore secure, policy this setting
should be disabled. Note that the value of this setting is ignored if
the value of getAllowUniversalAccessFromFileURLs()
is true
.
Note too, that this setting affects only JavaScript access to file scheme
resources. Other access to such resources, for example, from image HTML
elements, is unaffected. To prevent possible violation of same domain policy
when targeting Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and earlier,
you should explicitly set this value to false
.
The default value is true
for apps targeting
Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and below,
and false
when targeting Build.VERSION_CODES.JELLY_BEAN
and above.
Parameters | |
---|---|
flag |
boolean : whether JavaScript running in the context of a file scheme
URL should be allowed to access content from other file
scheme URLs
|
setAllowUniversalAccessFromFileURLs
public abstract void setAllowUniversalAccessFromFileURLs (boolean flag)
Sets whether JavaScript running in the context of a file scheme URL
should be allowed to access content from any origin. This includes
access to content from other file scheme URLs. See
setAllowFileAccessFromFileURLs(boolean)
. To enable the most restrictive,
and therefore secure policy, this setting should be disabled.
Note that this setting affects only JavaScript access to file scheme
resources. Other access to such resources, for example, from image HTML
elements, is unaffected. To prevent possible violation of same domain policy
when targeting Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and earlier,
you should explicitly set this value to false
.
The default value is true
for apps targeting
Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and below,
and false
when targeting Build.VERSION_CODES.JELLY_BEAN
and above.
Parameters | |
---|---|
flag |
boolean : whether JavaScript running in the context of a file scheme
URL should be allowed to access content from any origin
|
setAppCacheEnabled
public abstract void setAppCacheEnabled (boolean flag)
Sets whether the Application Caches API should be enabled. The default
is false
. Note that in order for the Application Caches API to be
enabled, a valid database path must also be supplied to
setAppCachePath(String)
.
Parameters | |
---|---|
flag |
boolean : true if the WebView should enable Application Caches
|
setAppCacheMaxSize
public abstract void setAppCacheMaxSize (long appCacheMaxSize)
This method was deprecated
in API level 18.
In future quota will be managed automatically.
Sets the maximum size for the Application Cache content. The passed size
will be rounded to the nearest value that the database can support, so
this should be viewed as a guide, not a hard limit. Setting the
size to a value less than current database size does not cause the
database to be trimmed. The default size is Long.MAX_VALUE
.
It is recommended to leave the maximum size set to the default value.
Parameters | |
---|---|
appCacheMaxSize |
long : the maximum size in bytes |
setAppCachePath
public abstract void setAppCachePath (String appCachePath)
Sets the path to the Application Caches files. In order for the Application Caches API to be enabled, this method must be called with a path to which the application can write. This method should only be called once: repeated calls are ignored.
Parameters | |
---|---|
appCachePath |
String : a String path to the directory containing
Application Caches files. |
See also:
setBlockNetworkImage
public abstract void setBlockNetworkImage (boolean flag)
Sets whether the WebView should not load image resources from the
network (resources accessed via http and https URI schemes). Note
that this method has no effect unless
getLoadsImagesAutomatically()
returns true
. Also note that
disabling all network loads using setBlockNetworkLoads(boolean)
will also prevent network images from loading, even if this flag is set
to false. When the value of this setting is changed from true
to false
,
network images resources referenced by content currently displayed by
the WebView are fetched automatically. The default is false
.
Parameters | |
---|---|
flag |
boolean : whether the WebView should not load image resources from the
network |
See also:
setBlockNetworkLoads
public abstract void setBlockNetworkLoads (boolean flag)
Sets whether the WebView should not load resources from the network.
Use setBlockNetworkImage(boolean)
to only avoid loading
image resources. Note that if the value of this setting is
changed from true
to false
, network resources referenced by content
currently displayed by the WebView are not fetched until
WebView.reload()
is called.
If the application does not have the
Manifest.permission.INTERNET
permission, attempts to set
a value of false
will cause a SecurityException
to be thrown. The default value is false
if the application has the
Manifest.permission.INTERNET
permission, otherwise it is
true
.
Parameters | |
---|---|
flag |
boolean : true means block network loads by the WebView |
See also:
setBuiltInZoomControls
public abstract void setBuiltInZoomControls (boolean enabled)
Sets whether the WebView should use its built-in zoom mechanisms. The
built-in zoom mechanisms comprise on-screen zoom controls, which are
displayed over the WebView's content, and the use of a pinch gesture to
control zooming. Whether or not these on-screen controls are displayed
can be set with setDisplayZoomControls(boolean)
. The default is false
.
The built-in mechanisms are the only currently supported zoom mechanisms, so it is recommended that this setting is always enabled.
Parameters | |
---|---|
enabled |
boolean : whether the WebView should use its built-in zoom mechanisms
|
setCacheMode
public abstract void setCacheMode (int mode)
Overrides the way the cache is used. The way the cache is used is based
on the navigation type. For a normal page load, the cache is checked
and content is re-validated as needed. When navigating back, content is
not revalidated, instead the content is just retrieved from the cache.
This method allows the client to override this behavior by specifying
one of LOAD_DEFAULT
,
LOAD_CACHE_ELSE_NETWORK
, LOAD_NO_CACHE
or
LOAD_CACHE_ONLY
. The default value is LOAD_DEFAULT
.
Parameters | |
---|---|
mode |
int : the mode to use
Value is |
setCursiveFontFamily
public abstract void setCursiveFontFamily (String font)
Sets the cursive font family name. The default is "cursive".
Parameters | |
---|---|
font |
String : a font family name
|
setDatabaseEnabled
public abstract void setDatabaseEnabled (boolean flag)
Sets whether the database storage API is enabled. The default value is
false. See also setDatabasePath(String)
for how to correctly set up the
database storage API.
This setting is global in effect, across all WebView instances in a process.
Note you should only modify this setting prior to making any WebView
page load within a given process, as the WebView implementation may ignore
changes to this setting after that point.
Parameters | |
---|---|
flag |
boolean : true if the WebView should use the database storage API
|
setDatabasePath
public abstract void setDatabasePath (String databasePath)
This method was deprecated
in API level 19.
Database paths are managed by the implementation and calling this method
will have no effect.
Sets the path to where database storage API databases should be saved. In order for the database storage API to function correctly, this method must be called with a path to which the application can write. This method should only be called once: repeated calls are ignored.
Parameters | |
---|---|
databasePath |
String : a path to the directory where databases should be
saved. |
setDefaultFixedFontSize
public abstract void setDefaultFixedFontSize (int size)
Sets the default fixed font size. The default is 16.
Parameters | |
---|---|
size |
int : a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.
|
setDefaultFontSize
public abstract void setDefaultFontSize (int size)
Sets the default font size. The default is 16.
Parameters | |
---|---|
size |
int : a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.
|
setDefaultTextEncodingName
public abstract void setDefaultTextEncodingName (String encoding)
Sets the default text encoding name to use when decoding html pages. The default is "UTF-8".
Parameters | |
---|---|
encoding |
String : the text encoding name
|
setDefaultZoom
public abstract void setDefaultZoom (WebSettings.ZoomDensity zoom)
This method was deprecated
in API level 19.
This method is no longer supported, see the function documentation for
recommended alternatives.
Sets the default zoom density of the page. This must be called from the UI
thread. The default is WebSettings.ZoomDensity.MEDIUM
.
This setting is not recommended for use in new applications. If the WebView
is utilized to display mobile-oriented pages, the desired effect can be achieved by
adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport'
tag. For pages lacking the tag, WebView.setInitialScale(int)
and setUseWideViewPort(boolean)
can be used.
Parameters | |
---|---|
zoom |
WebSettings.ZoomDensity : the zoom density |
setDisabledActionModeMenuItems
public abstract void setDisabledActionModeMenuItems (int menuItems)
Disables the action mode menu items according to menuItems
flag.
Parameters | |
---|---|
menuItems |
int : an integer field flag for the menu items to be disabled.
Value is either |
setDisplayZoomControls
public abstract void setDisplayZoomControls (boolean enabled)
Sets whether the WebView should display on-screen zoom controls when
using the built-in zoom mechanisms. See setBuiltInZoomControls(boolean)
.
The default is true
.
Parameters | |
---|---|
enabled |
boolean : whether the WebView should display on-screen zoom controls
|
setDomStorageEnabled
public abstract void setDomStorageEnabled (boolean flag)
Sets whether the DOM storage API is enabled. The default value is false
.
Parameters | |
---|---|
flag |
boolean : true if the WebView should use the DOM storage API
|
setEnableSmoothTransition
public abstract void setEnableSmoothTransition (boolean enable)
This method was deprecated
in API level 17.
This method is now obsolete, and will become a no-op in future.
Sets whether the WebView will enable smooth transition while panning or
zooming or while the window hosting the WebView does not have focus.
If it is true
, WebView will choose a solution to maximize the performance.
e.g. the WebView's content may not be updated during the transition.
If it is false, WebView will keep its fidelity. The default value is false
.
Parameters | |
---|---|
enable |
boolean |
setFantasyFontFamily
public abstract void setFantasyFontFamily (String font)
Sets the fantasy font family name. The default is "fantasy".
Parameters | |
---|---|
font |
String : a font family name
|
setFixedFontFamily
public abstract void setFixedFontFamily (String font)
Sets the fixed font family name. The default is "monospace".
Parameters | |
---|---|
font |
String : a font family name
|
setGeolocationDatabasePath
public abstract void setGeolocationDatabasePath (String databasePath)
This method was deprecated
in API level 24.
Geolocation database are managed by the implementation and calling this method
will have no effect.
Sets the path where the Geolocation databases should be saved. In order for Geolocation permissions and cached positions to be persisted, this method must be called with a path to which the application can write.
Parameters | |
---|---|
databasePath |
String : a path to the directory where databases should be
saved. |
setGeolocationEnabled
public abstract void setGeolocationEnabled (boolean flag)
Sets whether Geolocation is enabled. The default is true
.
Please note that in order for the Geolocation API to be usable by a page in the WebView, the following requirements must be met:
- an application must have permission to access the device location,
see
Manifest.permission.ACCESS_COARSE_LOCATION
,Manifest.permission.ACCESS_FINE_LOCATION
; - an application must provide an implementation of the
WebChromeClient.onGeolocationPermissionsShowPrompt(String, GeolocationPermissions.Callback)
callback to receive notifications that a page is requesting access to location via the JavaScript Geolocation API.
Parameters | |
---|---|
flag |
boolean : whether Geolocation should be enabled
|
setJavaScriptCanOpenWindowsAutomatically
public abstract void setJavaScriptCanOpenWindowsAutomatically (boolean flag)
Tells JavaScript to open windows automatically. This applies to the
JavaScript function window.open()
. The default is false
.
Parameters | |
---|---|
flag |
boolean : true if JavaScript can open windows automatically
|
setJavaScriptEnabled
public abstract void setJavaScriptEnabled (boolean flag)
Tells the WebView to enable JavaScript execution.
The default is false
.
Parameters | |
---|---|
flag |
boolean : true if the WebView should execute JavaScript
|
setLayoutAlgorithm
public abstract void setLayoutAlgorithm (WebSettings.LayoutAlgorithm l)
Sets the underlying layout algorithm. This will cause a re-layout of the
WebView. The default is WebSettings.LayoutAlgorithm.NARROW_COLUMNS
.
Parameters | |
---|---|
l |
WebSettings.LayoutAlgorithm : the layout algorithm to use, as a WebSettings.LayoutAlgorithm value
|
setLightTouchEnabled
public abstract void setLightTouchEnabled (boolean enabled)
This method was deprecated
in API level 18.
From Build.VERSION_CODES.JELLY_BEAN
this
setting is obsolete and has no effect.
Enables using light touches to make a selection and activate mouseovers.
Parameters | |
---|---|
enabled |
boolean |
setLoadWithOverviewMode
public abstract void setLoadWithOverviewMode (boolean overview)
Sets whether the WebView loads pages in overview mode, that is,
zooms out the content to fit on screen by width. This setting is
taken into account when the content width is greater than the width
of the WebView control, for example, when getUseWideViewPort()
is enabled. The default is false
.
Parameters | |
---|---|
overview |
boolean |
setLoadsImagesAutomatically
public abstract void setLoadsImagesAutomatically (boolean flag)
Sets whether the WebView should load image resources. Note that this method
controls loading of all images, including those embedded using the data
URI scheme. Use setBlockNetworkImage(boolean)
to control loading only
of images specified using network URI schemes. Note that if the value of this
setting is changed from false
to true
, all images resources referenced
by content currently displayed by the WebView are loaded automatically.
The default is true
.
Parameters | |
---|---|
flag |
boolean : whether the WebView should load image resources
|
setMediaPlaybackRequiresUserGesture
public abstract void setMediaPlaybackRequiresUserGesture (boolean require)
Sets whether the WebView requires a user gesture to play media.
The default is true
.
Parameters | |
---|---|
require |
boolean : whether the WebView requires a user gesture to play media
|
setMinimumFontSize
public abstract void setMinimumFontSize (int size)
Sets the minimum font size. The default is 8.
Parameters | |
---|---|
size |
int : a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.
|
setMinimumLogicalFontSize
public abstract void setMinimumLogicalFontSize (int size)
Sets the minimum logical font size. The default is 8.
Parameters | |
---|---|
size |
int : a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.
|
setMixedContentMode
public abstract void setMixedContentMode (int mode)
Configures the WebView's behavior when a secure origin attempts to load a resource from an
insecure origin.
By default, apps that target Build.VERSION_CODES.KITKAT
or below default
to MIXED_CONTENT_ALWAYS_ALLOW
. Apps targeting
Build.VERSION_CODES.LOLLIPOP
default to MIXED_CONTENT_NEVER_ALLOW
.
The preferred and most secure mode of operation for the WebView is
MIXED_CONTENT_NEVER_ALLOW
and use of MIXED_CONTENT_ALWAYS_ALLOW
is
strongly discouraged.
Parameters | |
---|---|
mode |
int : The mixed content mode to use. One of MIXED_CONTENT_NEVER_ALLOW ,
MIXED_CONTENT_ALWAYS_ALLOW or MIXED_CONTENT_COMPATIBILITY_MODE .
|
setNeedInitialFocus
public abstract void setNeedInitialFocus (boolean flag)
Tells the WebView whether it needs to set a node to have focus when
WebView.requestFocus(int, android.graphics.Rect)
is called. The
default value is true
.
Parameters | |
---|---|
flag |
boolean : whether the WebView needs to set a node
|
setOffscreenPreRaster
public abstract void setOffscreenPreRaster (boolean enabled)
Sets whether this WebView should raster tiles when it is
offscreen but attached to a window. Turning this on can avoid
rendering artifacts when animating an offscreen WebView on-screen.
Offscreen WebViews in this mode use more memory. The default value is
false.
Please follow these guidelines to limit memory usage:
- WebView size should be not be larger than the device screen size.
- Limit use of this mode to a small number of WebViews. Use it for visible WebViews and WebViews about to be animated to visible.
Parameters | |
---|---|
enabled |
boolean |
setPluginState
public abstract void setPluginState (WebSettings.PluginState state)
This method was deprecated
in API level 18.
Plugins are not supported in API level
Build.VERSION_CODES.KITKAT
or later;
enabling plugins is a no-op.
Tells the WebView to enable, disable, or have plugins on demand. On
demand mode means that if a plugin exists that can handle the embedded
content, a placeholder icon will be shown instead of the plugin. When
the placeholder is clicked, the plugin will be enabled. The default is
WebSettings.PluginState.OFF
.
Parameters | |
---|---|
state |
WebSettings.PluginState : a PluginState value |
setRenderPriority
public abstract void setRenderPriority (WebSettings.RenderPriority priority)
This method was deprecated
in API level 18.
It is not recommended to adjust thread priorities, and this will
not be supported in future versions.
Sets the priority of the Render thread. Unlike the other settings, this
one only needs to be called once per process. The default value is
WebSettings.RenderPriority.NORMAL
.
Parameters | |
---|---|
priority |
WebSettings.RenderPriority : the priority |
setSafeBrowsingEnabled
public abstract void setSafeBrowsingEnabled (boolean enabled)
Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links.
Safe Browsing can be disabled for all WebViews using a manifest tag (read general Safe Browsing info). The manifest tag has a lower precedence than this API.
Safe Browsing is enabled by default for devices which support it.
Parameters | |
---|---|
enabled |
boolean : Whether Safe Browsing is enabled.
|
setSansSerifFontFamily
public abstract void setSansSerifFontFamily (String font)
Sets the sans-serif font family name. The default is "sans-serif".
Parameters | |
---|---|
font |
String : a font family name
|
setSaveFormData
public abstract void setSaveFormData (boolean save)
Sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data. Therefore, the Webview form data save feature is disabled. Note that the feature will continue to be supported on older versions of Android as before. This function does not have any effect.
Parameters | |
---|---|
save |
boolean |
setSavePassword
public abstract void setSavePassword (boolean save)
This method was deprecated
in API level 18.
Saving passwords in WebView will not be supported in future versions.
Sets whether the WebView should save passwords. The default is true
.
Parameters | |
---|---|
save |
boolean |
setSerifFontFamily
public abstract void setSerifFontFamily (String font)
Sets the serif font family name. The default is "sans-serif".
Parameters | |
---|---|
font |
String : a font family name
|
setStandardFontFamily
public abstract void setStandardFontFamily (String font)
Sets the standard font family name. The default is "sans-serif".
Parameters | |
---|---|
font |
String : a font family name
|
setSupportMultipleWindows
public abstract void setSupportMultipleWindows (boolean support)
Sets whether the WebView whether supports multiple windows. If set to
true, WebChromeClient.onCreateWindow(WebView, boolean, boolean, Message)
must be implemented by the
host application. The default is false
.
Parameters | |
---|---|
support |
boolean : whether to support multiple windows
|
setSupportZoom
public abstract void setSupportZoom (boolean support)
Sets whether the WebView should support zooming using its on-screen zoom
controls and gestures. The particular zoom mechanisms that should be used
can be set with setBuiltInZoomControls(boolean)
. This setting does not
affect zooming performed using the WebView.zoomIn()
and
WebView.zoomOut()
methods. The default is true
.
Parameters | |
---|---|
support |
boolean : whether the WebView should support zoom
|
setTextSize
public void setTextSize (WebSettings.TextSize t)
This method was deprecated
in API level 14.
Use setTextZoom(int)
instead.
Sets the text size of the page. The default is WebSettings.TextSize.NORMAL
.
Parameters | |
---|---|
t |
WebSettings.TextSize : the text size as a WebSettings.TextSize value |
setTextZoom
public abstract void setTextZoom (int textZoom)
Sets the text zoom of the page in percent. The default is 100.
Parameters | |
---|---|
textZoom |
int : the text zoom in percent
|
setUseWideViewPort
public abstract void setUseWideViewPort (boolean use)
Sets whether the WebView should enable support for the "viewport"
HTML meta tag or should use a wide viewport.
When the value of the setting is false
, the layout width is always set to the
width of the WebView control in device-independent (CSS) pixels.
When the value is true
and the page contains the viewport meta tag, the value
of the width specified in the tag is used. If the page does not contain the tag or
does not provide a width, then a wide viewport will be used.
Parameters | |
---|---|
use |
boolean : whether to enable support for the viewport meta tag
|
setUserAgentString
public abstract void setUserAgentString (String ua)
Sets the WebView's user-agent string. If the string is null
or empty,
the system default value will be used.
Note that starting from Build.VERSION_CODES.KITKAT
Android
version, changing the user-agent while loading a web page causes WebView
to initiate loading once again.
Parameters | |
---|---|
ua |
String : new user-agent string
This value may be |
supportMultipleWindows
public abstract boolean supportMultipleWindows ()
Gets whether the WebView supports multiple windows.
Returns | |
---|---|
boolean |
true if the WebView supports multiple windows |
See also:
supportZoom
public abstract boolean supportZoom ()
Gets whether the WebView supports zoom.
Returns | |
---|---|
boolean |
true if the WebView supports zoom |
See also:
Annotations
Interfaces
Classes
- ClientCertRequest
- ConsoleMessage
- CookieManager
- CookieSyncManager
- DateSorter
- GeolocationPermissions
- HttpAuthHandler
- JsPromptResult
- JsResult
- MimeTypeMap
- PermissionRequest
- RenderProcessGoneDetail
- SafeBrowsingResponse
- ServiceWorkerClient
- ServiceWorkerController
- ServiceWorkerWebSettings
- SslErrorHandler
- TracingConfig
- TracingConfig.Builder
- TracingController
- URLUtil
- WebBackForwardList
- WebChromeClient
- WebChromeClient.FileChooserParams
- WebHistoryItem
- WebIconDatabase
- WebMessage
- WebMessagePort
- WebMessagePort.WebMessageCallback
- WebResourceError
- WebResourceResponse
- WebSettings
- WebStorage
- WebStorage.Origin
- WebView
- WebView.HitTestResult
- WebView.VisualStateCallback
- WebView.WebViewTransport
- WebViewClient
- WebViewDatabase
- WebViewFragment
Enums