The Safe-java-js-webview-bridge of hybrid development source analysis

Source: Internet
Author: User

Weekend time to see the next Safe-java-js-webview-bridge source code, organized a copy of the call between the class diagram.

The basic idea of the open Source Library is divided into three steps:

1. Write the class (such as Hostjsscope.java) that invokes the local function on the native side, and dynamically generate the JS code according to the class (in the Jscalljava constructor) when initializing webviewchromeclient;

2. The dynamically generated JS code is injected into the webview by Webview.loadurl triggered onprogresschanged, which can be called by the front end;

3. Call the Hostjsscope corresponding interface on the front-end, WebView the Onprompt event, and then call the local Hostjsscope method,

If it is synchronous and has a return value, returned by the prompt return value, and if it is asynchronous, reflection calls Jscallback to return the data to the front end.

It is time to parse the call relationship. (Forgive the errors in the diagram due to a lack of understanding of UML timing diagrams)

The Safe-java-js-webview-bridge of hybrid development source analysis

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.