Code example for WebView: Displaying web pages

Methods: addJavascriptInterfacegetSettingsloadUrlrestoreStatesetScrollBarStylesetWebViewClient

0
         
        BluelineWebView = (WebView) findViewById( R.id.webview );
        BluelineViewSwitcher = (ViewSwitcher) findViewById( R.id.viewSwitcher );
        BluelineHandler = new Handler();
 
        WebSettings webSettings = BluelineWebView.getSettings();
        webSettings.setJavaScriptEnabled( true );
        webSettings.setAppCacheMaxSize( 524288 );
        webSettings.setAppCachePath( "/data/data/uk.me.rsw.blueline/cache" );
        webSettings.setAllowFileAccess( true );
        webSettings.setAppCacheEnabled( true );
        webSettings.setCacheMode( WebSettings.LOAD_DEFAULT );
        webSettings.setDatabasePath( "/data/data/uk.me.rsw.blueline/cache" );
        webSettings.setDatabaseEnabled( true );
        webSettings.setDomStorageEnabled( true );
        webSettings.setSupportZoom( true );
        webSettings.setSaveFormData( false );
        try { 
			webSettings.setUserAgentString( getString( R.string.app_name )+" "+getPackageManager().getPackageInfo(getPackageName(), 0).versionName+" "+webSettings.getUserAgentString() );
		} catch (NameNotFoundException e) {
			Log.e("tag", e.getMessage());
		} 
         
        BluelineWebView.setWebViewClient( new BluelineWebViewClient() );
        BluelineWebView.addJavascriptInterface( new JavaScriptInterface( this ), "Android");
        BluelineWebView.setScrollBarStyle( WebView.SCROLLBARS_INSIDE_OVERLAY );
         
        if( savedInstanceState != null ) {
        	BluelineWebView.restoreState( savedInstanceState );
        } 
        else { 
	        BluelineWebView.loadUrl( "https://rsw.me.uk/blueline/" );
        } 
    } 
     
    /** Web Client */ 
    private class BluelineWebViewClient extends WebViewClient {