public abstract class WebSettings extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
WebSettings.CacheMode |
static class |
WebSettings.LayoutAlgorithm
Enum for controlling the layout of html.
|
static class |
WebSettings.PluginState
The plugin state effects how plugins are treated on a page.
|
static class |
WebSettings.RenderPriority |
static class |
WebSettings.TextSize
Deprecated.
Use
setTextZoom(int) and getTextZoom() instead. |
static class |
WebSettings.ZoomDensity
Enum for specifying the WebView's desired density.
|
Modifier and Type | Field and Description |
---|---|
static int |
LOAD_CACHE_ELSE_NETWORK
Use cached resources when they are available, even if they have expired.
|
static int |
LOAD_CACHE_ONLY
Don't use the network, load from the cache.
|
static int |
LOAD_DEFAULT
Default cache usage mode.
|
static int |
LOAD_NO_CACHE
Don't use the cache, load from the network.
|
static int |
LOAD_NORMAL
Deprecated.
This value is obsolete, as from API level
Build.VERSION_CODES.HONEYCOMB and onwards it has the
same effect as LOAD_DEFAULT . |
static int |
MENU_ITEM_NONE
Used with
setDisabledActionModeMenuItems(int) . |
static int |
MENU_ITEM_PROCESS_TEXT
Used with
setDisabledActionModeMenuItems(int) . |
static int |
MENU_ITEM_SHARE
Used with
setDisabledActionModeMenuItems(int) . |
static int |
MENU_ITEM_WEB_SEARCH
Used with
setDisabledActionModeMenuItems(int) . |
static 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. |
static 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. |
static 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. |
Constructor and Description |
---|
WebSettings() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
enableSmoothTransition()
Deprecated.
This method is now obsolete, and will become a no-op in future.
|
abstract boolean |
getAcceptThirdPartyCookies()
Gets policy for third party cookies.
|
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()
Deprecated.
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()
Deprecated.
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()
Deprecated.
This setting is obsolete.
|
abstract boolean |
getLoadsImagesAutomatically()
Gets whether the WebView loads image resources.
|
abstract boolean |
getLoadWithOverviewMode()
Gets whether this WebView loads pages in overview mode.
|
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 |
getNavDump()
Deprecated.
This method is now obsolete.
|
abstract boolean |
getOffscreenPreRaster()
Gets whether this WebView should raster tiles when it is
offscreen but attached to a window.
|
abstract boolean |
getPluginsEnabled()
Deprecated.
This method has been replaced by
getPluginState() |
String |
getPluginsPath()
Deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
|
abstract WebSettings.PluginState |
getPluginState()
Deprecated.
Plugins will not be supported in future, and should not be used.
|
abstract String |
getSansSerifFontFamily()
Gets the sans-serif font family name.
|
abstract boolean |
getSaveFormData()
Gets whether the WebView saves form data.
|
abstract boolean |
getSavePassword()
Deprecated.
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()
Deprecated.
Use
getTextZoom() instead. |
abstract int |
getTextZoom()
Gets the text zoom of the page in percent.
|
boolean |
getUseDoubleTree()
Deprecated.
This setting now has no effect.
|
abstract int |
getUserAgent()
Deprecated.
Please use
getUserAgentString() instead. |
abstract String |
getUserAgentString()
Gets the WebView's user-agent string.
|
abstract boolean |
getUseWebViewBackgroundForOverscrollBackground()
Deprecated.
This method is now obsolete.
|
abstract boolean |
getUseWideViewPort()
Gets whether the WebView supports the "viewport"
HTML meta tag or will use a wide viewport.
|
abstract boolean |
getVideoOverlayForEmbeddedEncryptedVideoEnabled()
Gets whether a video overlay will be used for embedded encrypted video.
|
abstract void |
setAcceptThirdPartyCookies(boolean accept)
Sets policy for third party cookies.
|
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)
Deprecated.
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)
Deprecated.
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)
Deprecated.
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
menuItems flag. |
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)
Deprecated.
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)
Deprecated.
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)
Deprecated.
From
Build.VERSION_CODES.JELLY_BEAN this
setting is obsolete and has no effect. |
abstract void |
setLoadsImagesAutomatically(boolean flag)
Sets whether the WebView should load image resources.
|
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 |
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 |
setNavDump(boolean enabled)
Deprecated.
This method is now obsolete.
|
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. |
abstract void |
setOffscreenPreRaster(boolean enabled)
Sets whether this WebView should raster tiles when it is
offscreen but attached to a window.
|
abstract void |
setPluginsEnabled(boolean flag)
Deprecated.
This method has been deprecated in favor of
setPluginState(android.webkit.WebSettings.PluginState) |
void |
setPluginsPath(String pluginsPath)
Deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
|
abstract void |
setPluginState(WebSettings.PluginState state)
Deprecated.
Plugins will not be supported in future, and should not be used.
|
abstract void |
setRenderPriority(WebSettings.RenderPriority priority)
Deprecated.
It is not recommended to adjust thread priorities, and this will
not be supported in future versions.
|
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)
Deprecated.
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)
Deprecated.
Use
setTextZoom(int) instead. |
abstract void |
setTextZoom(int textZoom)
Sets the text zoom of the page in percent.
|
void |
setUseDoubleTree(boolean use)
Deprecated.
This setting now has no effect.
|
abstract void |
setUserAgent(int ua)
Deprecated.
Please use
setUserAgentString(java.lang.String) instead. |
abstract void |
setUserAgentString(String ua)
Sets the WebView's user-agent string.
|
abstract void |
setUseWebViewBackgroundForOverscrollBackground(boolean view)
Deprecated.
This method is now obsolete.
|
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 |
setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag)
Sets whether to use a video overlay for embedded encrypted video.
|
abstract boolean |
supportMultipleWindows()
Gets whether the WebView supports multiple windows.
|
abstract boolean |
supportZoom()
Gets whether the WebView supports zoom.
|
public static final int LOAD_DEFAULT
setCacheMode(int)
.@Deprecated public static final int LOAD_NORMAL
Build.VERSION_CODES.HONEYCOMB
and onwards it has the
same effect as LOAD_DEFAULT
.setCacheMode(int)
.public static final int LOAD_CACHE_ELSE_NETWORK
setCacheMode(int)
.public static final int LOAD_NO_CACHE
setCacheMode(int)
.public static final int LOAD_CACHE_ONLY
setCacheMode(int)
.public static final int MIXED_CONTENT_ALWAYS_ALLOW
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.public static final int MIXED_CONTENT_NEVER_ALLOW
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.public static final int MIXED_CONTENT_COMPATIBILITY_MODE
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
.public static final int MENU_ITEM_NONE
setDisabledActionModeMenuItems(int)
.
No menu items should be disabled.public static final int MENU_ITEM_SHARE
setDisabledActionModeMenuItems(int)
.
Disable menu item "Share".public static final int MENU_ITEM_WEB_SEARCH
setDisabledActionModeMenuItems(int)
.
Disable menu item "Web Search".public static final int MENU_ITEM_PROCESS_TEXT
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.@Deprecated public abstract void setNavDump(boolean enabled)
@Deprecated public abstract boolean getNavDump()
setNavDump(boolean)
public abstract void setSupportZoom(boolean support)
setBuiltInZoomControls(boolean)
. This setting does not
affect zooming performed using the WebView.zoomIn()
and
WebView.zoomOut()
methods. The default is true.support
- whether the WebView should support zoompublic abstract boolean supportZoom()
setSupportZoom(boolean)
public abstract void setMediaPlaybackRequiresUserGesture(boolean require)
require
- whether the WebView requires a user gesture to play mediapublic abstract boolean getMediaPlaybackRequiresUserGesture()
setMediaPlaybackRequiresUserGesture(boolean)
public abstract void setBuiltInZoomControls(boolean enabled)
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.
enabled
- whether the WebView should use its built-in zoom mechanismspublic abstract boolean getBuiltInZoomControls()
setBuiltInZoomControls(boolean)
public abstract void setDisplayZoomControls(boolean enabled)
setBuiltInZoomControls(boolean)
.
The default is true.enabled
- whether the WebView should display on-screen zoom controlspublic abstract boolean getDisplayZoomControls()
setDisplayZoomControls(boolean)
public abstract void setAllowFileAccess(boolean allow)
public abstract boolean getAllowFileAccess()
setAllowFileAccess(boolean)
public abstract void setAllowContentAccess(boolean allow)
public abstract boolean getAllowContentAccess()
setAllowContentAccess(boolean)
public abstract void setLoadWithOverviewMode(boolean overview)
getUseWideViewPort()
is enabled. The default is false.public abstract boolean getLoadWithOverviewMode()
setLoadWithOverviewMode(boolean)
@Deprecated public abstract void setEnableSmoothTransition(boolean enable)
@Deprecated public abstract boolean enableSmoothTransition()
setEnableSmoothTransition(boolean)
@Deprecated public abstract void setUseWebViewBackgroundForOverscrollBackground(boolean view)
@Deprecated public abstract boolean getUseWebViewBackgroundForOverscrollBackground()
public abstract void setSaveFormData(boolean save)
public abstract boolean getSaveFormData()
setSaveFormData(boolean)
@Deprecated public abstract void setSavePassword(boolean save)
@Deprecated public abstract boolean getSavePassword()
setSavePassword(boolean)
public abstract void setTextZoom(int textZoom)
textZoom
- the text zoom in percentpublic abstract int getTextZoom()
setTextZoom(int)
public abstract void setAcceptThirdPartyCookies(boolean accept)
CookieManager#setShouldAcceptThirdPartyCookies
.public abstract boolean getAcceptThirdPartyCookies()
CookieManager#getShouldAcceptThirdPartyCookies
.public void setTextSize(WebSettings.TextSize t)
setTextZoom(int)
instead.WebSettings.TextSize.NORMAL
.t
- the text size as a WebSettings.TextSize
valuepublic WebSettings.TextSize getTextSize()
getTextZoom()
instead.setTextZoom(int)
, this will return the closest
matching WebSettings.TextSize
.WebSettings.TextSize
valuesetTextSize(android.webkit.WebSettings.TextSize)
@Deprecated public abstract void setDefaultZoom(WebSettings.ZoomDensity zoom)
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.zoom
- the zoom densitypublic abstract WebSettings.ZoomDensity getDefaultZoom()
setDefaultZoom(android.webkit.WebSettings.ZoomDensity)
@Deprecated public abstract void setLightTouchEnabled(boolean enabled)
Build.VERSION_CODES.JELLY_BEAN
this
setting is obsolete and has no effect.@Deprecated public abstract boolean getLightTouchEnabled()
setLightTouchEnabled(boolean)
@Deprecated public void setUseDoubleTree(boolean use)
@Deprecated public boolean getUseDoubleTree()
@Deprecated public abstract void setUserAgent(int ua)
setUserAgentString(java.lang.String)
instead.ua
- the integer code for the user-agent string@Deprecated public abstract int getUserAgent()
getUserAgentString()
instead.setUserAgentString(java.lang.String)
setUserAgent(int)
public abstract void setUseWideViewPort(boolean use)
use
- whether to enable support for the viewport meta tagpublic abstract boolean getUseWideViewPort()
setUseWideViewPort(boolean)
public abstract void setSupportMultipleWindows(boolean support)
WebChromeClient.onCreateWindow(android.webkit.WebView, boolean, boolean, android.os.Message)
must be implemented by the
host application. The default is false.support
- whether to suport multiple windowspublic abstract boolean supportMultipleWindows()
setSupportMultipleWindows(boolean)
public abstract void setLayoutAlgorithm(WebSettings.LayoutAlgorithm l)
WebSettings.LayoutAlgorithm.NARROW_COLUMNS
.l
- the layout algorithm to use, as a WebSettings.LayoutAlgorithm
valuepublic abstract WebSettings.LayoutAlgorithm getLayoutAlgorithm()
WebSettings.LayoutAlgorithm
valuesetLayoutAlgorithm(android.webkit.WebSettings.LayoutAlgorithm)
public abstract void setStandardFontFamily(String font)
font
- a font family namepublic abstract String getStandardFontFamily()
setStandardFontFamily(java.lang.String)
public abstract void setFixedFontFamily(String font)
font
- a font family namepublic abstract String getFixedFontFamily()
setFixedFontFamily(java.lang.String)
public abstract void setSansSerifFontFamily(String font)
font
- a font family namepublic abstract String getSansSerifFontFamily()
setSansSerifFontFamily(java.lang.String)
public abstract void setSerifFontFamily(String font)
font
- a font family namepublic abstract String getSerifFontFamily()
setSerifFontFamily(java.lang.String)
public abstract void setCursiveFontFamily(String font)
font
- a font family namepublic abstract String getCursiveFontFamily()
setCursiveFontFamily(java.lang.String)
public abstract void setFantasyFontFamily(String font)
font
- a font family namepublic abstract String getFantasyFontFamily()
setFantasyFontFamily(java.lang.String)
public abstract void setMinimumFontSize(int size)
size
- a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.public abstract int getMinimumFontSize()
setMinimumFontSize(int)
public abstract void setMinimumLogicalFontSize(int size)
size
- a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.public abstract int getMinimumLogicalFontSize()
setMinimumLogicalFontSize(int)
public abstract void setDefaultFontSize(int size)
size
- a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.public abstract int getDefaultFontSize()
setDefaultFontSize(int)
public abstract void setDefaultFixedFontSize(int size)
size
- a non-negative integer between 1 and 72. Any number outside
the specified range will be pinned.public abstract int getDefaultFixedFontSize()
setDefaultFixedFontSize(int)
public abstract void setLoadsImagesAutomatically(boolean flag)
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.flag
- whether the WebView should load image resourcespublic abstract boolean getLoadsImagesAutomatically()
setLoadsImagesAutomatically(boolean)
public abstract void setBlockNetworkImage(boolean flag)
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.flag
- whether the WebView should not load image resources from the
networksetBlockNetworkLoads(boolean)
public abstract boolean getBlockNetworkImage()
setBlockNetworkImage(boolean)
public abstract void setBlockNetworkLoads(boolean flag)
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
android.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
android.Manifest.permission#INTERNET
permission, otherwise it is
true.flag
- true means block network loads by the WebViewWebView.reload()
public abstract boolean getBlockNetworkLoads()
setBlockNetworkLoads(boolean)
public abstract void setJavaScriptEnabled(boolean flag)
flag
- true if the WebView should execute JavaScriptpublic abstract void setAllowUniversalAccessFromFileURLs(boolean flag)
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
on Build.VERSION_CODES.ICE_CREAM_SANDWICH
and earlier
devices, you should explicitly set this value to false
.
The default value is true for API level
Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and below,
and false for API level Build.VERSION_CODES.JELLY_BEAN
and above.
flag
- whether JavaScript running in the context of a file scheme
URL should be allowed to access content from any originpublic abstract void setAllowFileAccessFromFileURLs(boolean flag)
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
on Build.VERSION_CODES.ICE_CREAM_SANDWICH
and earlier
devices, you should explicitly set this value to false
.
The default value is true for API level
Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
and below,
and false for API level Build.VERSION_CODES.JELLY_BEAN
and above.
flag
- whether JavaScript running in the context of a file scheme
URL should be allowed to access content from other file
scheme URLs@Deprecated public abstract void setPluginsEnabled(boolean flag)
setPluginState(android.webkit.WebSettings.PluginState)
flag
- true if plugins should be enabled@Deprecated public abstract void setPluginState(WebSettings.PluginState state)
WebSettings.PluginState.OFF
.state
- a PluginState value@Deprecated public void setPluginsPath(String pluginsPath)
pluginsPath
- a String path to the directory containing plugins@Deprecated public abstract void setDatabasePath(String databasePath)
databasePath
- a path to the directory where databases should be
saved.@Deprecated public abstract void setGeolocationDatabasePath(String databasePath)
databasePath
- a path to the directory where databases should be
saved.public abstract void setAppCacheEnabled(boolean flag)
setAppCachePath(java.lang.String)
.flag
- true if the WebView should enable Application Cachespublic abstract void setAppCachePath(String appCachePath)
appCachePath
- a String path to the directory containing
Application Caches files.setAppCacheEnabled(boolean)
@Deprecated public abstract void setAppCacheMaxSize(long appCacheMaxSize)
Long.MAX_VALUE
.
It is recommended to leave the maximum size set to the default value.appCacheMaxSize
- the maximum size in bytespublic abstract void setDatabaseEnabled(boolean flag)
setDatabasePath(java.lang.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.flag
- true if the WebView should use the database storage APIpublic abstract void setDomStorageEnabled(boolean flag)
flag
- true if the WebView should use the DOM storage APIpublic abstract boolean getDomStorageEnabled()
setDomStorageEnabled(boolean)
@Deprecated public abstract String getDatabasePath()
setDatabasePath(java.lang.String)
public abstract boolean getDatabaseEnabled()
setDatabaseEnabled(boolean)
public abstract void setGeolocationEnabled(boolean flag)
Please note that in order for the Geolocation API to be usable by a page in the WebView, the following requirements must be met:
android.Manifest.permission#ACCESS_COARSE_LOCATION
,
android.Manifest.permission#ACCESS_FINE_LOCATION
;
WebChromeClient.onGeolocationPermissionsShowPrompt(java.lang.String, android.webkit.GeolocationPermissions.Callback)
callback
to receive notifications that a page is requesting access to location
via the JavaScript Geolocation API.
flag
- whether Geolocation should be enabledpublic abstract boolean getJavaScriptEnabled()
setJavaScriptEnabled(boolean)
public abstract boolean getAllowUniversalAccessFromFileURLs()
setAllowUniversalAccessFromFileURLs(boolean)
public abstract boolean getAllowFileAccessFromFileURLs()
setAllowFileAccessFromFileURLs(boolean)
@Deprecated public abstract boolean getPluginsEnabled()
getPluginState()
setPluginsEnabled(boolean)
@Deprecated public abstract WebSettings.PluginState getPluginState()
WebSettings.PluginState
valuesetPluginState(android.webkit.WebSettings.PluginState)
@Deprecated public String getPluginsPath()
public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean flag)
flag
- true if JavaScript can open windows automaticallypublic abstract boolean getJavaScriptCanOpenWindowsAutomatically()
setJavaScriptCanOpenWindowsAutomatically(boolean)
public abstract void setDefaultTextEncodingName(String encoding)
encoding
- the text encoding namepublic abstract String getDefaultTextEncodingName()
setDefaultTextEncodingName(java.lang.String)
public abstract void setUserAgentString(String ua)
Build.VERSION_CODES.KITKAT
Android
version, changing the user-agent while loading a web page causes WebView
to initiate loading once again.ua
- new user-agent stringpublic abstract String getUserAgentString()
setUserAgentString(java.lang.String)
public static String getDefaultUserAgent(Context context)
setUserAgentString(String)
.context
- a Context object used to access application assetspublic abstract void setNeedInitialFocus(boolean flag)
WebView.requestFocus(int, android.graphics.Rect)
is called. The
default value is true.flag
- whether the WebView needs to set a node@Deprecated public abstract void setRenderPriority(WebSettings.RenderPriority priority)
WebSettings.RenderPriority.NORMAL
.priority
- the prioritypublic abstract void setCacheMode(int mode)
LOAD_DEFAULT
,
LOAD_CACHE_ELSE_NETWORK
, LOAD_NO_CACHE
or
LOAD_CACHE_ONLY
. The default value is LOAD_DEFAULT
.mode
- the mode to usepublic abstract int getCacheMode()
setCacheMode(int)
public abstract void setMixedContentMode(int mode)
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.mode
- The mixed content mode to use. One of MIXED_CONTENT_NEVER_ALLOW
,
MIXED_CONTENT_ALWAYS_ALLOW
or MIXED_CONTENT_COMPATIBILITY_MODE
.public abstract int getMixedContentMode()
MIXED_CONTENT_NEVER_ALLOW
,
MIXED_CONTENT_ALWAYS_ALLOW
or MIXED_CONTENT_COMPATIBILITY_MODE
.public abstract void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag)
Build.VERSION_CODES.LOLLIPOP
, encrypted video can
only be rendered directly on a secure video surface, so it had been a hard problem to play
encrypted video in HTML. When this flag is on, WebView can play encrypted video (MSE/EME)
by using a video overlay (aka hole-punching) for videos embedded using HTML <video>
tag.public abstract boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled()
setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean)
public abstract void setOffscreenPreRaster(boolean enabled)
public abstract boolean getOffscreenPreRaster()
public abstract void setDisabledActionModeMenuItems(int menuItems)
menuItems
flag.menuItems
- an integer field flag for the menu items to be disabled.public abstract int getDisabledActionModeMenuItems()
MENU_ITEM_NONE