Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does WebView in the SDK source code extend MockView?

In my android studio, I find the WebView source code, but it seems to be empty, and the top comment is:

/**
* Mock version of the WebView.
* Only non override public methods from the real WebView have been added in there.
* Methods that take an unknown class as parameter or as return object, have been removed for now.
* 
* TODO: generate automatically.
*
*/

But in the github android source code, it is not like this, and it seems this is the real WebView.

So my question is why there are the the two different WebView source codes, and what is MockView

like image 263
lirui Avatar asked Aug 13 '15 08:08

lirui


People also ask

What is MockView in Android?

We can define android MockView widget as below – MockView is a widget that is used to create prototype of a design we want to create for our application.

How do you override a WebView?

If you want to override certain methods, you have to create a custom WebView class which extends WebView . Also, when you are inflating the WebView , make sure you are casting it to the correct type which is CustomWebView . CustomWebView webView = (CustomWebView) findViewById(R. id.

Is WebView open source?

Since Android 4.4 (KitKat), the WebView component is based on the Chromium open source project. WebViews now include an updated version of the V8 JavaScript engine and support for modern web standards previously missing in old WebViews.

Which method can be used to retrieve WebSettings?

Configuring WebView Settings with WebSettings getSettings() object if a WebView is already destroyed. You can retrieve WebSettings with WebView. getSettings() API.


1 Answers

In the provided scope, the WebView in android.jar is a mock version, which is only for development purpose, with the mock version webview you can render the webview in the layout window, you can call the API in your code.

In the runtime scope, the WebView will be replaced.

like image 172
srain Avatar answered Sep 24 '22 12:09

srain