Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webview does not show onConsoleMessage in android

I have used webview

with the reference http://developer.android.com/guide/webapps/debugging.html

  myWebView.getSettings().setJavaScriptEnabled(true);

myWebView.setWebChromeClient(new WebChromeClient() {
   public boolean onConsoleMessage(ConsoleMessage cm) {
              Log.d("MyApplication", cm.message() + " -- From line "
                                   + cm.lineNumber() + " of "
                                   + cm.sourceId() );
              return true;
            }
            public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                Log.d("MyApplication", message + " -- From line "
                                     + lineNumber + " of "
                                     + sourceID);
              }
});

but still m not get log Logcat

Please help me out

like image 200
Parag Chauhan Avatar asked Oct 26 '25 06:10

Parag Chauhan


1 Answers

It appears some devices (HTC Desire and some others) with specific OS (mine had 2.3.3) do not display messages in Logcat window and it seems console.log does not work for them. I found a nice workaround using JavaScript Interface to overcome the issue: Android Console via JS interface

like image 60
morgan_il Avatar answered Oct 28 '25 20:10

morgan_il



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!