开发者

Possible to receive UIAccelerometer updates when app is inactive?

When my iPhone app resigns active status, the sharedAccelerometer singleton instance of UIAccelerometer stops sending accelerometer:didAccelerate: messages to my delegate.

Is it at all possible to continue receiving those messa开发者_StackOverflow社区ges, similarly to how the CLLocationManagerDelegate continues to receive updates when the app is inactive?

I would prefer not to have to disable the idleTimer altogether if it can be helped.


No, not in the most recent available form of the iPhone SDK at least.


I would say that it is possible since this app is on the AppStore:

However, since you move differently in bed during the different phases, the Sleep Cycle alarm clock is able to use the accelerometer in your iPhone to monitor your movement and determine which sleep phase you are in.

I can't believe it has to run all night with the screen turned on. EDIT: looks like it has to! :P


So they haven't got around that issue either. More chances that you can't achieve it then...

Have you read the documentation of the UIAccelerometer, does it mention anything there? If it just stops sending acceleration events there is not much you can do.

I would however try to set the accelerometer delegate again to my class when my app has lost focus (when the phone got locked). You can get that notification (lost focus notification) from the UIApplication. Try that just in case the accelerometer's delegate gets set to nil when the app loses focus.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜