Hello there,
I've an app
class KronosHBDFApp extends Application.AppBase {
function initialize() {
AppBase.initialize();
uname=null;
pwd=null;
jsonloaded=false;
dataj=null;
timeDLJson=null;
if(Sto.getValue("jsondata")==null){
if(Toybox.System has :ServiceDelegate) {
Background.registerForTemporalEvent(new Time.Duration(5 * 60));
} else {
Sys.println("****background not available on this device****");
}
Background.registerForOAuthResponseEvent();
}
}
(:background)
function onBackgroundData(data) {
Sys.println("obg ");
}
function getServiceDelegate(){
Sys.println("getServiceDelegate ");
return [new JsonBackground()];
}
}a background class
(:background)
class JsonBackground extends Toybox.System.ServiceDelegate {
var realtoken;
function initialize() {
Sys.ServiceDelegate.initialize();
realtoken=null;
}
/***********/
function handleAccessResponseJsonHB(responseCode, data) {
Sys.println("handleAccessResponseJsonHB");
// If we got data back then we were successful. Otherwise
// pass the error onto the delegate
if( data != null) {
Sys.println("data handleAccessResponseJsonHB OK "+data);
} else {
Sys.println("Error in handleAccessResponseJsonHB "+responseCode + " " + data);
}
var ret=null;
if(Sto.getValue("token")==null){
ret={"token"=>realtoken,"jsondata"=>data};
Sys.println("case1");
}else{
ret={"token"=>Sto.getValue("token"),"jsondata"=>data};
Sys.println("case2");
}
Sys.println(ret);
Bg.exit(ret);
}
} and a view
class KronosHBDFView extends WatchUi.DataField {
function onUpdate(dc) {
Sys.println("onupdate");
}
}the "Sys.println(ret);" is visible but not Sys.println("obg "); visual studio exit and Sys.println("onupdate"); stop to be printed after