简体   繁体   中英

Send data from JS to parent with PhoneGap

I am experimenting with PhoneGap on Android and am embedding the CordovaWebView in an Activity that implements the CordovaInterface . I want to know if it is possible to send some data from JavaScript to the parent that contains the CordovaWebView .

In the CordovaInterface there is a method onMessage and I assumed that it would be possible to handle messages from JS there, but I can't seem to find documentation on how that works.

In this question I saw that creating a plugin would do it, but is that the only way? Isn't there something that is already implemented in PhoneGap.

This may or may not help you but if you want to see an example of how a plugin is implemented I've done this on my blog . It does allow you to communicate between the two and is probably your best bet in doing so. My understanding is this is the reasoning for the plugin interface in PhoneGap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM