Android webview interacts with javascript, androidwebview

Source: Internet
Author: User

Android webview interacts with javascript, androidwebview

HTML5 app development has the advantages of fast development and cross-platform. However, when a customer needs to access a camera or call a camera or other hardware, H5 has restrictions and must call native methods for device access. The following describes how JS and native Methods call each other:

1. Configure in webview. First, access through JS and JS interfaces is supported:

Here, JSHook is a Java class:

Here we only demonstrate how JS can call hardware, but it does not upload photos to the server.

2 JS method writing

The JSHook object registered above, and for kz in JS, the root node is window, that is, window. kz. QR () is JSHook. QR () in webview ()

3. effect Preview

Click scan,

 

Related Article

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.