Android WebView Development Specific Explanation (III)

Source: Internet
Author: User

Reprint Please specify the source http://blog.csdn.net/typename/article/details/40302351powered by Miechal Zhao

At a glance, Android WebView provides a showcase page, as well as some customization of our application to page loading, for example, we can set the current loading page to reduce the network data to display the picture, assuming that the PC URL on the pad to access the user can provide an overview mode of browsing, Ability to provide customized features such as enlarged web fonts.

Android offers some setting class websettings for managing WebView. The WebSettings object is also created at the same time when the WebView object is created, with the default settings value. WebSettings objects can be obtained through webview.getsettings ().

The life cycle of the websettings is the same as the WebView life cycle, assuming that WebView is destroy WebSettings should be released, otherwise assuming WebSettings continues to operate, Throws an exception illegalstateexception.
The 1.WebSettings API specifically explains that all functions that call websettings settings are made asynchronously. So we set a state that does not take effect immediately.

Public synchronized void Setloadsimagesautomatically (Boolean flag)

Sets whether the current WebView needs to load the picture, which controls the state of the entire webview and takes such a strategy for all resources. If set to False then the current URL of the visit so that the picture resource will not be loaded. The default value is true.
Public synchronized void Setblocknetworkimage (Boolean flag)

This method is valid when Getloadsimagesautomatically returns True, with the default value: false;
public void Setcachemode (int mode)
A normal web page loading cache will be checked and the contents will be verified again. The first time you visit a webpage, the cache is stored locally, and the settings policy can change how the page is loaded. The cache mode has several examples:
Load_default: Suppose our application is not set up no matter what cachemode. This is the default cache mode. Loading a webpage will check if there is a cache. The local cache is assumed to be available and not expired, otherwise it is obtained from the network.


Load_cache_else_network: Use the CACHE resource. Even if it expires, it is assumed that no cache is available from the network.
Load_no_cache: Do not use CACHE all to get from the network
Load_cache_only: Just use the content on the CACHE.

public void Setloadwithoverviewmode (Boolean overview)
The setting of the overview mode, which defaults to false.
Public synchronized void setjavascriptenabled (Boolean flag)
The default value is False. Suppose we need JavaScript on our web page. This setting needs to be turned on. Otherwise, the page is not loaded completely.
2.WebSettings WebKit in the implementation of the Webseetings API in the Android system each version number is not only the addition of API or deprecate some API, but its internal is actually different version number of some differences. The mainstream Android version is now mostly Android 4.0. Analysis of more than 4.0 of the system version number to achieve the implementation of webseetings is divided into three pieces of Android 4.0, Android 4.1---4.3,android 4.4. The following analysis is implemented between Android versions:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdhlwzw5hbwu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>
1) Android 4.0 system is mainly divided into two parts, part of the API layer, the other part of the settings storage location.

Settings storage location Most of the setting is finally set to WebCore where the Settings.cpp, for example javascriptenable and other parts of the module based on the relevant storage within the modules, For example, Cachemode is stored in Frameloader.

2) The Android 4.1--4.3 system reconstructs the framework of the WebView, and the websettings correspondence changes accordingly. The middle of the bridge class was introduced WEBSETTINGSCLASSC. Settings storage location Most of the setting is finally set to WebCore where the Settings.cpp, for example javascriptenable and other parts of the platform-related storage in the Webcoresupport layer corresponding module. For example, on 4.1---4.3 cachemode stored in Webrequestcontext


On Android 4.4 The WebView bottom implementation replaced the chromium, in order to be compatible with the old WebSettings interface, Android 4.4 made the chromium of the bridge class, The main involved websettings related code in contentsettingsadapter,awsettings. As with some of the previous version numbers, most settings are still stored in the WebKit Settings.cpp. This is an introduction to the Blink rendering engine used by chromium. And Blink is from the WebKit which stripped out, but also retained the WebKit parsing and so on. So the folder structure will be different from the Settings.cpp stored in the WebCore folder that we saw earlier. Another part of settings on Android 4.4 is also stored on the platform porting layer.

Here is an analysis of this setting for Cachemode:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdhlwzw5hbwu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>


References: Http://developer.android.com/reference/packages.html#q=websettingshttps://source.android.com/Android 4.0-- -4.4


Android WebView Development Specific Explanation (III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.