Search code examples
windows-phone-7trackingaccelerometer

Track Accelerometer under lock screen


Is it possible to track the accelerometer value while under the lock screen?

I managed to write a simple application which counts from 1 up to 100 using a timer which fires an event on which I increment a counter.

But when I use register a handler for the ReadingChanged event of the accelerometer it will not be fired anymore once the screen has been locked. Even if I unlock the screen again I will have to readd my handler.


Solution

  • the msdn documentation tells on the one page: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff941090(v=vs.105).aspx "Valid reasons to disable idle detection in Windows Phone OS 7.1 applications include ones where core functionality continues while the phone is locked (for instance, an exercise tracking app)"

    but the sensor api also tells: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202968(v=vs.105).aspx

    "The Sensor APIs cannot be used while the application is running under the lock screen. For more information, see Idle Detection for Windows Phone. The Sensor APIs also cannot be used in background agents. For more information, see Background Agents Overview for Windows Phone"

    I hope they will change the api soon, because of that it is not possible to write any good sleep tracking / sport tracking applications ... :(