Java Plug-in development in phonegap and java calling by javascript

Source: Internet
Author: User

Someone has asked this question: How does js in phonegap call a local java program? It can be implemented using the principle of plug-in development. It seems that there are other methods. The following is a simple process of plug-in development, so that js can also call java code .. Www.2cto.com

You can encapsulate the functions implemented by java code into a plug-in of phonegap, such as class MyPlugin extends Plugin, and rewrite its method to implement the functions you need. Add <plugin name = "MyPlugin" value = "MyPlugin class full name"/> to res/xml/plugins. xml. Then, you can use cordova.exec(such as cordova.exe c (null, null, 'mypugin', 'Action', data) in cordova.jsto call the execute method of MyPlugin.


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.