If we want to provide a web application (or just a web page) as part of the client application, we can use WebView. The WebView class is an extension of the Android View class. It allows you to display some of the Active la s on the web page. It does not include any fully developed web browser features, such as navigation controls or an address bar. All webviews are displayed on a web page by default.
What are the application scenarios of Webview? We can use WebView to display and provide some information. For example, you may need to update it, such as an end-user protocol or user guide. In your Android Application, you can create an Acitivity containing WebView. And then use it to display the online documents you host. In another scenario, WebView always requires a network connection to retrieve data, such as email, if your application provides data to users. In this case, you may find that creating a WebView shows all user data on a web page of the Android application, rather than executing a network request, it is easy to parse the data and present it in an Android layout. Some steps to call WebView are as follows:
(1)
Add the WebView control to your application. You only need to include the Layout of the <WebView> element in the activity.
(2)
Use loadUrl () to load a WebView.
WebView myWebView = (WebView) findViewById(R.id.webview);myWebView.loadUrl("http://www.example.com");
(3)
Add network authorization in the configuration file
...
If you plan to use JavaScript in WebView on the web page of your load, you must enable JavaScript WebView. Once JavaScript is enabled, you can also create interfaces between your application code and JavaScript code. JavaScript is disabled by default in WebView. You can enable WebSettings. You can search for WebSettings () with getSettings, and then enable JavaScript () with setJavaScriptEnabled ().
WebView myWebView = (WebView) findViewById(R.id.webview);WebSettings webSettings = myWebView.getSettings();webSettings.setJavaScriptEnabled(true);