11

We're using WebViews to display web pages behind a https scheme and intentionally display "insecure content" (non-https resources) on it for performance but the WebView constantly outputs logcat warning messages. Is there anyway to disable/hide them?

It can technically leak sensitive URLs to anything that can read the logcat output, so it would be really great to be able 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.

Oak Bytes
  • 4,649
  • 4
  • 36
  • 53
Grantland Chew
  • 2,620
  • 26
  • 26

1 Answers1

14

It's possible.

Just override WebViewClient for your WebView like this:

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 out the log line or just create a Log class and disable logging when doing release build.

Sergii
  • 1,521
  • 3
  • 24
  • 37
MadDeveloper
  • 796
  • 11
  • 20