Using HTML5 to develop Android (3)---debugging in Android

Source: Internet
Author: User

Output log information via JS code
JS Code
JS Code: Console.log ("Hello World");   Log info: Console:hello World http://www.example.com/hello.html:82   
Implement the Onconsolemesaage () callback method in webchromeclient to print information in Logcat
Java code
 1  WebView mywebview = (WebView)   Findviewbyid (R.id.webview);  2  mywebview.setwebchromeclient (new   Webchromeclient () { 3  public  void  onconsolemessage (String message, int   linenumber, String SourceID) { 4  log.d ("MyApplication", "Message +"--From line "5  + linenumber + "of" 6  + SourceID);  7  }  }); 
And
Java code
1WebView Mywebview =(WebView) Findviewbyid (R.id.webview); 2Mywebview.setwebchromeclient (Newwebchromeclient () {3      Public Booleanonconsolemessage (consolemessage cm) {4LOG.D ("MyApplication", cm.message () + "-From line"5+ cm.linenumber () + "of"6+Cm.sourceid ()); 7         return true; 8     }   9});
*consolemessage also includes a messagelevel that represents the console delivery information type. You can use Messagelevel () to query the information level to determine the severity of the information, and then use the appropriate log method or take other appropriate actions.

Using HTML5 to develop Android (3)---debugging in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.