Code example for WebView: Displaying web pages

Methods: addJavascriptInterfacegetSettingsloadUrlsetWebViewClient, setId

0
		TextView tv = new TextView(this);
		tv.setText("Loading..");
		this.setContentView(tv);
		final Context context = this;
 
		WebView webView = new WebView(this);
	 	webView.getSettings().setJavaScriptEnabled(true);
		WebViewClient yourWebClient = new WebViewClient()
		{ 
			@Override 
			public boolean shouldOverrideUrlLoading(WebView view, String url)
			{ 
				view.loadUrl(url);
				return false; 
			} 
 
		}; 
		webView.setWebViewClient(yourWebClient);
		webView.setId(111);
		  
 
		class JavaScriptInterface 
		{ 
			Context mContext;
 
			/** Instantiate the interface and set the context */ 
			JavaScriptInterface(Context c)
			{ 
				mContext = c;
			} 
 
			public void setCookies(String cookiesStr)
			{ 
			 	Helper.setCookies(cookiesStr);  
				// CookieSyncManager.getInstance().sync(); 
		  
				Runnable run = new Runnable()
				{ 
					public void run() 
					{ 
						startAppListActivity(); 
					} 
				}; 
				 runOnUiThread(run); 
			} 
		} 
	 	webView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
 
		webView.loadUrl( Helper.getLoginURL());
		setContentView(webView);
	} 
 
	@Override 
	protected void onPause() 
Connect your IDE to all the code out there  Get Codota for Java