Disable webview messages from logcat output

We use WebViews to display web pages behind the https scheme and intentionally display “insecure content” (resources other than https) for this, but WebView constantly displays logcat warning messages. Is there any way to disable / hide them?

It can technically leak sensitive URLs to everything that logcat output can read, so it would be great to hide it.

07-10 11:42:56.198: W/Web Console(32423): The page at https://secure_url displayed insecure content from http://insecure_url.

+6
source share
1 answer

It is possible.

Just override the WebViewClient for your WebView as follows:

 webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage cm) { Log.d("TAG", cm.message() + " at " + cm.sourceId() + ":" + cm.lineNumber()); return true; } }); 

You can, of course, comment on a log line or simply create a log class and disable logging when creating an assembly.

+7
source

Source: https://habr.com/ru/post/920149/


All Articles