Detailed introduction to Android and H5 intermodulation
Detailed introduction to Android and H5 intermodulation
Wechat, microblog, wechat, QQ space, a large number of software use embedded H5. At this time, it is necessary to understand how Android interacts with H5 more; In order to save costs, some outsourcing companies adopt Android embedded H5 mode for development, which is convenient for direct reuse of pages on IOS and finally solve the cost.
Why should I learn Android H5?
Many Android Software have embedded H5. What are the uses and advantages? Save cost and improve development efficiency.
What is the principle of implementation?
The essence is: Java code and JavaScript calls
Case 1: simple intermodulation between Java and JS
First, load the H5 page in the Android Code:
JavaAndJavaScriptCall.html:
Java calls javascript:
JavaScript calls Java
Case 2: H5 page calls Android to play video
After understanding the simple call, the following is simple:
1_ Layout and instantiation control of jscalljavavideoactivity
2_ Instantiate the control and configure it
3_ Load page
4_ Reference JS code to write java called code
5_ Configuring JavaScript interfaces
6_ JavaScript interface class
Case 3: H5 page calls Android to make a call
1_ Jscalljavacallphoneactivity layout
2_ Initialize WebView and configure
3_ Load the jscalljavacallphone.html page
4_ Passing JSON data from Java code to JavaScript
5_ Call code
6_ H5 page:
Thank you for reading, hope to help you, thank you for your support to this site!