Android WebView Control


Android webView is used to display the content in the web browser content in Android devices. We are using Android palette toolbox to drag and drop the controls in design interface provided by Android Studio. Here, webView control is used to display the content of the web browser which has .htm or .html extension file. WebView can also be used by declaring html tags in string datatype. The content of the browser is adjustable according to the device size. It has two methods loadData and loadUrl.

In loadData, we have to declare string datatype variable which consists HTML tags and related data in it while in loadUrl you can declare URL of a webpage from where the data is coming. Along with these methods, we can also use other methods that can be used for full functioning web browser data. There are many methods as follow as: -

canGOBack() : This method is used to go backwards when browser has history or previously visited window.

canGoForForward(): This method can be used to move forward direction of the web browser or requesting for new content.

clearHistory(): It is used to clear the previously visited URL web pages from the browser.

clearCache(): This method is used to delete the cache data such as cookies, bookmarks etc.

Autofill(SpareArray[]): it is used when you want to fill all content which is same previously used then this feature fill the data corresponding to their child.

getTittle() : it holds the title of web page.

getUrl();- it brings the URL which the user has requested.

getProgress() :- it returns the progress going on the web browser. To show progress on the Activity title bar, we use getWindows().getFeatures(Windows.FEATURE_PROGRESS) , where FEATURE_PROGESSS is constant value.

 To get the settings of web browser, we can use webview object and followed by dot operator with getSettings() method and enable and disable features

                         Ex: - webviewObject.getSettings().SetJavaScriptEnabled(true);

 To handle the content on the web browser we can declare setWebChrome() listener with the webview object.

 To enable zoom in and out feature in your application, we can use setBultinZoomControls(true);

 For safe browsing ability in your application and devices, we can declare following tag in Android_Manifest.xml

<meta-data android:name=”android.webkit.WebView.EnabledSafeBrowsing” android:value=”true”/>

 To get content online from the browser URL and display it , we can declare tag in Android_Manifest.xml

	 <uses-permission android:name=”android.permission.INTERNET”


<?xml version='1.0' encoding='utf-8'?>

<manifest xmlns:android=''

        <activity android:name='.MainActivity'>
                <action android:name='android.intent.action.MAIN' />

                <category android:name='android.intent.category.LAUNCHER' />

<?xml version='1.0' encoding='utf-8'?>


        android:layout_height='match_parent' />
package com.mapsample.msclient009.webview;

        import android.os.Bundle;
        import android.view.Menu;
        import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {
    WebView webView;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate ( savedInstanceState );
        setContentView ( R.layout.activity_main );
        webView =(WebView)findViewById ( );
        String url = '<html><head></head><body><h1 style='font-family:sans-serif;color:#FF0044; font-size:1.2em;'>Hello Android</h1><p align=\'center\' style=\'font-family:new times roman\'>\n' +
                'The content is design for webView technology in Android. In this technology, we learn about fetching and supplying into the devices.\n' +
          webView.loadData ( url,'text/html','UTF-8' );

                                   Android WebView Control

Last updated:9/7/2019 12:17:58 AM


Leave Comment