In Android, JavaScript is implemented in WebView to call the method of Java class

In order to facilitate the interaction between web pages and Android applications, the Android system provides a mechanism for javascript web page scripts in WebView to call Java class methods. Just call the addjavascriptinterface method to map a Java object to a JavaScript object.

1. Mapping Java objects to JavaScript objects

2. JavaScript call Java object example

Call the back method of the above jsinvokeclass class object, as follows:

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
分享
二维码
< <上一篇
下一篇>>