Hi, Bret
If your purpose is just to send JSON data from Java side to Javascript, I think
the Crosswalk extension could satisfy your requirement since it can support
two-way communication between java side and javascript side.
Generally, the Crosswalk extension is based on message passing between browser
(Java side) and render (Javascript side), and the message is using JSON format.
To send data from Java side to Javascript, you can invoke postMessage with the
data, and if you set the message listener in extension JS code, the listener
could receive the data posted by postMessage in Java code.
The sample code may look like as below:
// Java side code: YourExtension.java
public class YourExtension extends XWalkExtensionClient {
public void doSomething() {
String jsonData = "{...}";
postMessage(instanceId, jsonData);
}
}
// JavaScript code: your_extension_api.js
extension.setMessageListener(function(json){
console.log("You receive json data from java side: " + json);
});
You can reference
https://crosswalk-project.org/#wiki/Writing-a-Crosswalk-Java-Extension-on-Android
for more information about Crosswalk extension.
If you encounter any problem in writing Crosswalk extension, feel free to let
us know.
Thanks...
Hongbo
From: Crosswalk-help
[mailto:[email protected]] On Behalf Of Bret
Zarkiewicz
Sent: Thursday, April 24, 2014 11:10 PM
To: [email protected]
Subject: [Crosswalk-help] WebView to Native code integration
I completely understand that JavaScript can call Java code but the reverse
direction is not supported. Does writing a Java Crosswalk Extension on Android
get around this limitation? Basically what I want to do is send a message with
JSON data from Java code to the WebView.
https://crosswalk-project.org/#wiki/Android-WebView
Bret
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help