Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetInitialScalesetWebChromeClientsetWebViewClient, setOnTouchListener

0
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.web_authorise);
 
		webView = (WebView) findViewById(R.id.webView);
		webView.getSettings().setJavaScriptEnabled(true);
 
		webView.setWebChromeClient(new WebChromeClient() {
			public void onProgressChanged(WebView View, int progress) {
				GitHubAppActivity.this.setProgress(progress * 1000);
			} 
		}); 
		webView.loadUrl("https://github.com/login/oauth/authorize?client_id=81e06b06df8444dfc400&scope=repo");
		// https://github.com/login/oauth/authorize?client_id=81e06b06df8444dfc400 
 
		webView.setWebViewClient(new AuthClient());
 
		webView.setOnTouchListener(new View.OnTouchListener() {
 
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub 
				WebView.HitTestResult hr = ((WebView) v).getHitTestResult();
				Log.i("******", "getExtra = " + hr.getExtra() + "\t\t Type=" + hr.getType());
 
				return false; 
			} 
		}); 
		webView.setInitialScale(1);
		Log.i("-----------", "-----------");
	} 
 
	private class AuthClient extends WebViewClient {
		@Override 
Experience pair programming with AI  Get Codota for Java