views:

57

answers:

1

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.

A: 

Hi,

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

Kay
Here Marco set up a detailed description: http://blog.marcopeluso.com/2009/08/23/how-to-prevent-iphone-from-deep-sleeping/
Kay
just tried it out. Its still not working. Although the sound plays every 5 seconds I still cant get any data from the accelerometer.
Jason
Strange. Is there any action stopping accelerometer in AppDelegate's applicationWillResignActive method. There is another question dealing with this problem and there it works that way: http://stackoverflow.com/questions/2529422/enable-iphone-accelerometer-while-screen-is-locked
Kay