Cordova exec success function not called (Android) -




the java plugin updates boolean in timezonevariables true/false if device's timezone changes while app in background. call plugin when app resumes boolean value, , prints "getistimezonechanged true", not print "timezone did change".

the $log.debug javascript function works fine, console.log. relevent code below if can tell me why exec successcallback isn't being called.

java code:

@override public boolean execute(string action, jsonarray data, callbackcontext callbackcontext) throws jsonexception {     if(action.equals("createtimezonechangelistener")) {         timezonevariables.setcallbackcontext(callbackcontext);         timezonevariables.setistimezonechanged(false);     }else if(action.equals("checktimezonechange")){         if (timezonevariables.getistimezonechanged()){             log.d("timezoneupdater","getistimezonechanged true");             timezonevariables.setistimezonechanged(false);             return true;         } else return false;             }     return true; } 

javascript proxy:

function timezoneupdater() {  }  timezoneupdater.prototype = {     checktimezonechange: function (changedcallback) {         cordova.exec(changedcallback, null, "timezoneupdater", "checktimezonechange", []);     } }  module.exports = {     createtimezonechangelistener: function(){                cordova.exec(null, null, "timezoneupdater", "createtimezonechangelistener", []);                 return new timezoneupdater();     } }; 

www javascript code:

  var ref = window.timezoneupdater.createtimezonechangelistener();   document.addeventlistener("resume", function(){     ref.checktimezonechange(function(){       //timezone did change while app in background       $log.debug("timezone did change");     });   }, false); 

thats because never invoke callback in native implementation. cordova not automatically call success callback function, have using callbackcontext this:

if (timezonevariables.getistimezonechanged()) {   callbackcontext.success("timezone changed"); // can pass whatever want here   return true; else {   callbackcontext.error("timezone did not change"); // have pass error callback   return false; } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -