Code example for WebView: Displaying web pages

Methods: clearCacheclearFormDataclearHistorygetSettingsloadUrlsetWebChromeClientsetWebViewClient

0
		 
		Log.d(TAG, "Displaying url in web view.");
		p = ProgressDialog.show(this, getString(R.string.loading), getString(R.string.loadingActivities));
		 
		final WebView wv = (WebView) this.findViewById(R.id.webview);
		wv.getSettings().setJavaScriptEnabled(true);
		wv.clearFormData();
		wv.clearHistory();
		wv.clearCache(true);
		 
		wv.setWebViewClient(new WebViewClient() {
			@Override 
			public void onReceivedSslError(WebView view,
					SslErrorHandler handler, SslError error) {
				handler.proceed();
			} 
		}); 
		 
		wv.setWebChromeClient(new WebChromeClient() {
			@Override 
			public void onProgressChanged(WebView view, int newProgress) {
				if (newProgress == 100) {
					p.dismiss();
				} 
			} 
		}); 
		 
		final String url = ApplicationUtil.getServerBaseUrl(getApplicationContext()) + "/mobile/start";
		Log.d(TAG, "Load url: " + url);
		 
		final String session = NetcareApp.getCurrentSession();
		if (session == null) {
			throw new IllegalStateException("Order reference is not set.");
		} 
		 
		final Map<String, String> headers = new HashMap<String, String>();
		headers.put("X-netcare-order", NetcareApp.getCurrentSession());
		wv.loadUrl(url, headers);
	} 
	 
	@Override 
    public boolean onCreateOptionsMenu(Menu menu) {
    	startActivity(new Intent(getApplicationContext(), PreferenceActivity.class));
Stop searching for code, let great code find you!  Add Codota to your java IDE