Search code examples
iosios5uiaccelerometer

Test Whether the screen is ON/OFF in iphone


I am developing a application to test whether the iphone screen is OFF or ON and i tried the code of accelerometer that specified in stack overflow it working well for screen on status but when i turn off the screen the accelerometer is not deactivating.

So i am getting doubt about the fact that did really accelerometer get deactivate automatically when the screen turns off. If anybody having clear idea about it please share it.

Thanks


Solution

  • Application are paused when it sleep. You should realize a background task for it.

    https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20