Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetHttpAuthUsernamePasswordsetScrollBarStylesetWebChromeClientsetWebViewClient, requestFocusFromTouch

0
	 
	/* 
	 * Create a WebView with the sensible defaults, and load a url within it 
	 */ 
	public static WebView launchUrl(Activity activity, String url, String user, String pass) {
		WebView webView = new WebView(activity);
		webView.setWebChromeClient(new WebChromeClient());
		webView.setWebViewClient(new CouchUtils.CustomWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setDomStorageEnabled(true);
		webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
		// TODO: read host / realm from config 
		webView.setHttpAuthUsernamePassword("127.0.0.1", "administrator", user, pass);
		webView.requestFocusFromTouch();
		webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		activity.setContentView(webView);
		webView.loadUrl(url);
		return webView;
	}; 
 
	 
	public static String readAsset(AssetManager assets, String path) throws IOException {
Stop searching for code, let great code find you!  Add Codota to your java IDE