Android calls JS, and JS calls Android

1.main.xml

2.demo.html

3.WebViewDemo.java

When you click the button in the first interface, the HTML content changes

MainActivity.java

Note: there are two ways to solve the problem that the WebView. Addjavascriptinterface interface does not work

① For version changed to 16

② Add @ javascriptinterface annotation to the method of JavaScript interface class

2. Example of JavaScript calling Java object

demo1.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>