Code example for ConsoleMessage

Methods: lineNumber, message, sourceId

0
      Activity activity, String gaeUrl, MessageHandler handler) {
    webView = new WebView(activity);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new WebChromeClient() {  // Purely for debugging.
        public boolean onConsoleMessage (ConsoleMessage msg) {
          Log.d(TAG, "console: " + msg.message() + " at " +
              msg.sourceId() + ":" + msg.lineNumber());
          return false; 
        } 
      }); 
    webView.setWebViewClient(new WebViewClient() {  // Purely for debugging.
        public void onReceivedError( 
            WebView view, int errorCode, String description,
            String failingUrl) {
          Log.e(TAG, "JS error: " + errorCode + " in " + failingUrl +
              ", desc: " + description);
        } 
      }); 
    proxyingMessageHandler = new ProxyingMessageHandler(activity, handler);
    webView.addJavascriptInterface(
        proxyingMessageHandler, "androidMessageHandler");