class ObjectStore extends App.AppBase
{
function onStart() {
Sys.println("Enter App.onStart()");
var n = getProperty("xxx");
if (n == null) {
Sys.println("didn't find property, setting to 98");
setProperty("xxx", 98);
}
else {
Sys.println("found property has value " + n);
}
Sys.println("Exit App.onStart()");
}
function onStop() {
Sys.println("Enter App.onStop()");
Sys.println("setting to 99");
setProperty("xxx", 99);
Sys.println("Exit App.onStop()");
}
function getInitialView()
{
return [new View(), new Input()];
}
}
I see the following output when the application starts up and shuts down...
Device Version 0.1.0
Device id 1 name "A garmin device"
Shell Version 0.1.0
Enter App.onStart()
didn't find property, setting to 98
Exit App.onStart()
// terminate app
Enter App.onStop()
setting to 99
Exit App.onStop()
Complete
Enter App.onStop()
setting to 99
Exit App.onStop()
I see this every time that the application runs. There are a few issues with this. First off, the onStop() method is getting called twice. Second, the attempt to overwrite the persistent value while the application is cleaning up fails (the persistent value is not found on every execution of the program. Third, if you comment out the code in onStop(), you'll notice that overwriting the value in onStart() doesn't seem to take effect either.
Travis