Ok, but I want to know if I can recover the information if the user is gonna to switch off the watch, like a flag or a event when the watch is gonna to turn off ? (I'm working on a Forerunner 235).
You can't see this specific event, but when the watch turns off, your app may exit in the normal way, and you can save things at that point. What kind of things are you looking to save? Are you looking at this for a watch-app? Why would anyone turn off the watch while it's running?
jim_m_58 I'm working on an experimentation, and we ask our user to never switch off the app. But, if they did it, I would like to write a message in the logs file to be able to save the information. I'm working on a watch-app. Brian.ConnectIQ Ok tjhanks for your help.
If you only need to know the app was never closed, then you can write to the persistent storage in onStop(). This method should get called regardless of whether the application is exited normally, or if the device is switched off.
If you only need to know the app was never closed, then you can write to the persistent storage in onStop(). This method should get called regardless of whether the application is exited normally, or if the device is switched off.
Would this event also occur when the device is Forced shutdown/powercycled? How about device crashes...?
writing an increasing counter to persistent storage during oncompute is probably slower but a safer implementation
onStop() can't be called if the device hard crashes, or if the device is forced off using whatever methods are in place to recover from software lockups.
I don't think this is a data field, and writing in compute() seems like overkill if it was. If you want to cover those cases, you could increment a persisted counter in onStart() to know the number of times the application has started. This would need to use the new Application.Storage module for persisting content, as the older Application.Appbase.setProperty storage is not persisted if the application does not exit cleanly.