Can't seem to figure this out even after looking at some code from starttorun.info as well as the forums.
The call --> requestApplicationWake gets executed even though there is no temporal event registered. Is this the correct behaviour or likely I'm doing it all wrong
Widget Logic
1) widget In foreground -> Grabs a location and user has ability to store it into object store.
2) user goes back to watch face (Widget dismissed)--> a BG Event is registered.
3) Upon Temporal Event happening (using the sim), onTemporalEvent gets called requestApplicationWake comes out.
if there are NO location stored in the Object Store, then I would not register the Background Event, but requestApplicationWake gets executed anyways
Now, if I were to remove any references to registerTemporalEvent, I stop the App in the simulator, then execute a Background Event from the simulator, the requestApplicationWake still gets executed. I'm sure that there was ways to do some sort of conditional checks within onTemporalEvent hence I'm likely missing something.
Appreciate any pointers.
App.AppBase
(:background) function onStop(state) { System.println("App.onStop"); if(Sys has :ServiceDelegate) { if ( App.Storage.getValue(A_COORDINATES) == null ) { Sys.println("App.Deleting Temporal Event"); Bg.deleteTemporalEvent(); } else { Sys.println("App.Temporal Event Present"); } } function getInitialView() { System.println("App.getInitialView"); if(Sys has :ServiceDelegate) { if ( App.Storage.getValue(A_COORDINATES) != null ) { Sys.println("App.Registering Temporal Event " + App.Storage.getValue(A_COORDINATES)); // Bg.registerForTemporalEvent(new Time.Duration(5 * 60)); } else { Sys.println("App.Not Registering Temporal Event"); } }
System.ServiceDelegate
function onTemporalEvent() { Background.requestApplicationWake("Your timer has expired!"); } Background.exit(); }
I've also tried to do a conditional check, but it seems like whether the object store is NULL or NON-NULL, the requestApplicationWake doesn't get executed anyways.
function onTemporalEvent() { if ( App.Storage.getValue(A_COORDINATES) != null ) { Background.requestApplicationWake("Your timer has expired!"); } Background.exit(); }