Android JS and Local code interaction---jsbridge usage precautions

Source: Internet
Author: User

Recent projects need to use the local navigation bar, but the content display still needs HTML5 display to improve the quality of the interaction.

Jsbridge is using an open source project on GitHub (to determine what version of an as is available), and there is nothing to be aware of when using the Android studio environment.

But there are a few things to be aware of when porting to the Eclipse environment:

1, for the network environment to read the Web page, to provide interactive interface, you need to do JS injection,

The method is to fully read the JS file data into the use of WebView to load the JS code, Webview.loadurl ("javascript:" + Jscode);

PS: This part in the debugging is a problem, that is, although the JS file is completely read, but after injection did not take effect, and later found that there is no processing of special characters in the JS code caused.

2, to change the declared object name, some of the associated class name also needs to be modified, and the name of JS also needs to be modified, a single modification of a part will also cause the call to not take effect.

3, the data obtained by the segmentation when the judgment of the split point needs to be based on their own actual situation to deal with.

Ps:as uses "/" to split, because the data in the project is a JSON object, where the internal data contains a portion of the network address, resulting in data being split multiple times.

The last data you get is part of the data being split.

4. Finally, there are some trivial problems such as small empty sentences.

Android JS and Local code interaction---jsbridge usage precautions

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.