Code example for ConsoleMessage

Methods: lineNumber, message, messageLevel, sourceId

0
	private void setupWebView(WebView webView) {
		webView.getSettings().setJavaScriptEnabled(true);
		 
		webView.setWebChromeClient(new WebChromeClient() {
			public boolean onConsoleMessage(ConsoleMessage cm) {
				if (cm.messageLevel() == ConsoleMessage.MessageLevel.LOG) {
					Log.i("mobile_planner.js", cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
				} 
				if (cm.messageLevel() == ConsoleMessage.MessageLevel.WARNING) {
					Log.w("mobile_planner.js", cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
				} 
				if (cm.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
					Log.e("mobile_planner.js", cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
				} 
				return true; 
			} 
		}); 
		 
		webView.setWebViewClient(new WebViewClient() {
			@Override 
			public void onPageFinished(WebView view, String url) {