Information when watch is turning off

Former Member
Former Member
Hi, I would like to know if the user turns off his watch, can I recover this information (I want to save data before the watch turn off)?
  • Yes, an app can save data to Application.Storage/ the Object Store. There are samples of both in the SDK samples directory.
  • Former Member
    Former Member
    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?
  • Former Member
    Former Member
    There is no way for an application to know if the user turned their device off.
  • Former Member
    Former Member
    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.
  • Former Member
    Former Member
    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.
  • Former Member
    Former Member
    I will try this tommorow. Thanks for your answer.
  • 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
  • Former Member
    Former Member
    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.
  • Yes, he said it was a watch app - on a fr235 - which means he can't use Application.Storage as it's CIQ1.