开发者

Reading accelerometer after screen lock

开发者 https://www.devze.com 2023-01-15 11:38 出处:网络
Hi I have an app that reads data from the accelerometer. However after the screen gets locked this not possible.

Hi I have an app that reads data from the accelerometer. However after the screen gets locked this not possible.

I have tried the following

-(void)startMonitoring{
    UIApplication *thisApp = [UIApplication sharedApplication];
    thisApp.idleTimerDisabled = YES;
        ....
        ....
}

-(void)stopMonitoring{
    UIApplication *thisApp = [UIApplication sharedApplication];
    thisApp.idleTimerDisabled = NO;
        ....
        ....
}

How can I keep reading from the accelerometer even after the screen gets locked. 开发者_高级运维


as I understand you, you don't want to disable screen locking in general by using:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

There is a code sample at github.com playing a sound every x seconds even if the device is in standby mode:

http://github.com/marcop/MMPDeepSleepPreventer

The author just uses a timer firing every few seconds. I haven't tried it out yet, but it should work according to forum posts.

Kay

0

精彩评论

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