Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points of WebSettings?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the knowledge points of WebSettings". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the knowledge points of WebSettings"?

Whether WebSettings webSettings=webView.getSettings (); setAllowContentAccess (boolean allow) allows access to content URL (Content Url) in WebView is allowed by default. Content Url access allows WebView to load content from content providers installed on the system.

Whether setAllowFileAccess (boolean allow) allows access to files is allowed by default. Note that access to the file system is only allowed or disabled, and Assets and resources files are still accessible using file:///android_asset and file:///android_res.

Whether setAllowFileAccessFromFileURLs (boolean flag) allows JavaScript running in a URL environment (the context of a file scheme URL) to access content from other URL environments should not be allowed for security. Also note that this setting only affects JavaScript access to file schema resources, and other forms of access, such as those from the picture HTML unit, are not affected. To prevent the same domain policy (same domain policy) from infringing ICE_CREAM_SANDWICH and older models, you should explicitly set this value to false.

Whether setAllowUniversalAccessFromFileURLs (boolean flag) allows JavaScript running in a file schema URL environment to access content from any other source, including other file schema URLs. See setAllowFileAccessFromFileURLs (boolean), to ensure security, it should be set to not allowed. Note that this setting only affects JavaScript access to file schema resources, and other forms of access, such as those from the picture HTML unit, are not affected. To prevent the same domain policy (same domain policy) from infringing ICE_CREAM_SANDWICH and older models, you should explicitly set this value to false. ICE_CREAM_SANDWICH_MR1 and older versions this default is true,JELLY_BEAN and newer this default is false

SetAppCacheEnabled (boolean flag) whether the application cache API is available. The default is false, which is used in combination with setAppCachePath (String).

SetAppCachePath (String) sets the path where the cache file is applied. In order for the application cache API to be available, this method must pass in an application writable path. The method is executed only once, and repeated calls are ignored.

SetAppCacheMaxSize (long appCacheMaxSize) is obsolete. Sets the maximum value for applying cached content. The value passed is approximated to the closest value supported by the database, so this is an indicative value, not a fixed value. If the passed value is less than the database size, the database will not be resized. The default value is MAX_VALUE, and it is recommended that you set the default value to the maximum.

Whether setBlockNetworkImage (boolean flag) disables downloading of image resources from the network (resources accessed through http and https URI schemes). The default value is false. Note that this method is not valid unless getLoadsImagesAutomatically () returns true. Also note that even if this setting is false, using setBlockNetworkLoads (boolean) to disable all network loading will prevent the loading of network images. When the value of this setting changes from true to false,WebView, the network image resources referenced by the currently displayed content will be automatically obtained.

Whether setBlockNetworkLoads (boolean flag) prohibits downloading data from the network. If app has INTERNET permission, the default value is false, otherwise it defaults to true. Using setBlockNetworkImage (boolean) only disables the loading of image resources. Note that this value changes from true to false, and the network resources referenced by the content displayed by the current WebView are not automatically loaded until an overload is called. If APP does not have INTERNET permission, setting this value to false throws a SecurityException.

Whether setBuiltInZoomControls (boolean enabled) uses the built-in scaling mechanism. The built-in zoom mechanism includes on-screen zoom controls (floating on WebView content) and the use of zoom gestures. You can control whether these controls are displayed through setDisplayZoomControls (boolean), and the default value is false.

SetCacheMode (int mode) overrides the way the cache is used, with the default value of LOAD_DEFAULT. The cache is used based on the navigation type, normal page loading, cache detection, and cache content reproduction when needed. When the navigation returns, the content will not be reproduced, only the content will be recovered from the cache disk. This method allows the client to override its behavior by specifying one of the items LOAD_DEFAULT, LOAD_CACHE_ELSE_NETWORK, and LOAD_NO_CACHE or LOAD_CACHE_ONLY.

SetCursiveFontFamily (String font) sets WebView font library font, default "cursive"

Whether the setDatabaseEnabled (boolean flag) database stores API is available, the default is false. How to set up the data store API correctly see setDatabasePath (String). This setting is valid for all WebView instances in the same process. Note that this can only be modified before any WebView of the current process loads the page, because the WebView implementation class after this node may ignore the change in this setting.

SetDatabasePath (String databasePath) is obsolete, the database path is managed by the implementation (implementation), and calling this method is invalid. Set the storage path of the database, in order to ensure that the database runs correctly, this method must use an application writable path. This method can only be executed once, and repeated calls are ignored.

SetDefaultFixedFontSize (int size) sets a fixed font size by default. Default is 16. Values range from 1 to 72.

SetDefaultFontSize (int size) sets the default font size, which defaults to 16. Values range from 1 to 72.

SetDefaultTextEncodingName (String encoding) sets the default character coding set, default "UTF-8".

SetDefaultZoom (WebSettings.ZoomDensity zoom) is obsolete. To set the default zoom density, it must be called in the UI thread. The default value is MEDIUM. This setting is not recommended for new applications. If WebView is used to display mobile pages, you can achieve the desired results by adjusting the width' and initial-scale' attributes in the 'meta viewport' tag' of the page. For pages with missing tags, you can use setInitialScale (int) and setUseWideViewPort (boolean).

SetDisplayZoomControls (boolean enabled) whether to display the zoom control when using the built-in zoom mechanism, the default value is true. See setBuiltInZoomControls (boolean).

SetDomStorageEnabled (boolean flag) DOM stores whether API is available, default false.

SetEnableSmoothTransition (boolean enable) has been discarded and will become a no-op in the future. Set whether to allow a smooth transition when panning or zoom or hold the window of the current WebView without focus. If it is true,WebView, you will choose a solution that maximizes performance. For example, the contents of WebView may not be updated during the transition. If false,WebView maintains precision (fidelity), the default is false.

SetFantasyFontFamily (String font) sets the name of fantasy font set (font family) to "fantasy" by default

SetFixedFontFamily (String font) sets the name of the fixed font set, which defaults to "monospace".

SetGeolocationDatabasePath (String databasePath) locates the save path of the database. In order to ensure the persistence of location permissions and cache locations, this method should pass in an application writable path.

Whether setGeolocationEnabled (boolean flag) positioning is available, the default is true. Please note that in order to ensure that the location API is available in the WebView page, the following convention must be observed: (1) app must have location permission, see ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION; (2) app must provide the implementation of onGeolocationPermissionsShowPrompt (String, GeolocationPermissions.Callback) callback method, and receive notification when the page requests location through JavaScript location API. Optionally, you can store historical locations and Web initial permissions in the database, see setGeolocationDatabasePath (String).

SetJavaScriptCanOpenWindowsAutomatically (boolean flag) lets JavaScript open the window automatically, which defaults to false. Applies to the JavaScript method window.open ().

SetJavaScriptEnabled (boolean flag) sets whether WebView allows the execution of JavaScript scripts, default false, not allowed.

SetLayoutAlgorithm (WebSettings.LayoutAlgorithm l) sets the layout, which will cause the relayout of WebView (relayout). The default is NARROW_COLUMNS.

SetLightTouchEnabled (boolean enabled) is obsolete. Starting with JELLY_BEAN, this setting is not valid. Allows you to make selections and hover with a light touch.

Whether setLoadWithOverviewMode (boolean overview) allows the webview degree to load the page in the way of overview, default false. That is, reduce the content to fit the width of the screen. This setting takes effect when the content width exceeds the width of the WebView control, such as when getUseWideViewPort () returns true.

Whether setLoadsImagesAutomatically (boolean flag) WebView downloads image resources. Default is true. Note that this method controls the download of all pictures, including those embedded with URI (using setBlockNetworkImage (boolean) only controls the download of pictures using network URI). If the value of this setting is changed from false to true,WebView, all image resources referenced by the content displayed will be downloaded automatically.

Whether the setMediaPlaybackRequiresUserGesture (boolean require) WebView requires a user's gesture for media playback. The default is true.

SetMinimumFontSize (int size) sets the smallest font size, default to 8

SetMinimumLogicalFontSize (int size) sets the smallest local font size, default to 8.

SetMixedContentMode (int mode) configure the behavior of WebView when a secure source (origin) attempts to load resources from an insecure source. By default, KITKAT and earlier versions default to MIXED_CONTENT_ALWAYS_ALLOW,LOLLIPOP version defaults. The safest mode of operation preferred by MIXED_CONTENT_NEVER_ALLOW,WebView is MIXED_CONTENT_NEVER_ALLOW, and MIXED_CONTENT_ALWAYS_ALLOW is discouraged.

Whether setNeedInitialFocus (boolean flag) needs to set the node to get focus when calling requestFocus (int, Android.graphics.Rect). The default value is true.

SetOffscreenPreRaster (boolean enabled) whether or not raster tiles when the WebView switches to the background but is still associated with the window, turn it on to avoid redrawing when the WebView switches from the background to the foreground. The default is false. In this mode, the background WebView takes up more memory. Please show the use of memory according to the following guidelines:

The size of the WebView cannot be larger than the screen size of the device; the use of this mode is restricted to a small number of WebView; it is used on the visible WebView and the upcoming WebView; setPluginState (WebSettings.PluginState state) is abandoned above API18. Plug-ins will not be supported in the future. Do not use them. Tell WebView to enable, disable or have plug-ins that are ready to use (on demand). The use mode means that if there is a plug-in that can handle embedded content, a placeholder icon will be displayed and turned on when clicked. The default is OFF.

SetRenderPriority (WebSettings.RenderPriority priority) has been abandoned above API18. Adjusting thread priorities is not recommended and will not be supported in future versions. Set the priority of rendering (Render, translated into rendering in many books, seemingly professional, but difficult to understand, disagree with) threads. Unlike other settings, it only needs to be called once in the same process, and the default is NORMAL.

SetSansSerifFontFamily (String font) sets the name of the sans serif font set (sans-serif font family). The default is "sans-serif".

Whether the setSaveFormData (boolean save) WebView saves the form data, the default is true.

Versions above setSavePassword (boolean save) API18 are obsolete. Saving passwords in WebView will not be supported in future releases. Sets whether WebView saves the password. The default is true.

SetSerifFontFamily (String font) sets the name of the serif font set (serif font family). The default is "sans-serif".

SetStandardFontFamily (String font) sets the name of the standard font set, with the default value of "sans-serif".

SetSupportMultipleWindows (boolean support) sets whether WebView supports multiple windows. If set to true, the main program implements onCreateWindow (WebView, boolean, boolean, Message), which defaults to false.

Whether setSupportZoom (boolean support) WebView supports zooming using on-screen zoom controls and gestures, the default is true. Setting setBuiltInZoomControls (boolean) can use a special scaling mechanism. This setting does not affect the zoom operation of zoomIn () and zoomOut ().

SetTextSize (WebSettings.TextSize t) API14 version and above is obsolete. Please use setTextZoom (int) instead. Sets the size of the page text, the default NORMAL.

SetTextZoom (int textZoom) sets the percentage of text zoom on the page, which defaults to 100.

Whether the setUseWideViewPort (boolean use) WebView supports the "viewport" tag of HTML or uses wide viewport. When set to true, the width of the layout is always the same as the device independent pixel (device-dependent pixels) width on the WebView control. When the value is true and the page contains a viewport tag, the width specified by the tag is used. If the page does not contain a tag or if the tag does not provide a width, use wide viewport.

SetUserAgentString (String ua) sets the user agent string for WebView. If the string is null or empty, the system default value is used. Note that starting with the KITKAT version, changing the user agent while loading the web page will cause WebView to initialize the load again.

SupportMultipleWindows () gets the value of whether WebView supports multiple windows.

SupportZoom () gets the value of whether WebView supports scaling

Thank you for your reading, the above is the content of "what are the WebSettings knowledge points". After the study of this article, I believe you have a deeper understanding of what WebSettings knowledge points have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report