I am attempting to use the following plugin and am having a problem accessing the JAVA result in JS.
Below is a short version on the plugin that relates
Java:
public void sendCallback(String action, ServiceInfo info) {
JSONObject status = new JSONObject();
try {
status.put("action", action);
status.put("service", jsonifyService(info));
Log.d("ZeroConf", "Sending result: " + status.toString());
PluginResult result = new PluginResult(PluginResult.Status.OK,
status);
result.setKeepCallback(true);
this.callback.sendPluginResult(result);
} catch (JSONException e) {
e.printStackTrace();
}
}
JS
var ZeroConf = {
watch: function (type, callback) {
return exec(function (result) {
if (callback) {
callback(result);
}
}, ZeroConf.fail, "ZeroConf", "watch", [type]);
}};module.exports = ZeroConf;
In my html file I am trying to show the result and nothing is working! I am not very familiar with JAVA so I am not sure where the source of my issue it.
Sample HTML File:
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
ZeroConf.watch('_http._tcp.local.', function(result) {
This is where I dont know how to access the result from JAVA
alert(result)
// do something with the result
});
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}};
Notes: Im sure its working because I can see the results from the JAVA side "Log.d"