问题
My application needs the screen be unlocked to do some functions, usually this app runs as background process, how can I prevent auto-lock? I mean on jailbroken environment.
Why does the code below can not be available from SpringBoard?
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
回答1:
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
回答2:
Have a look on SpringBoard
class
This code should be run in SpringBoard:
SpringBoard *sb = [UIApplication sharedApplication];
[sb clearIdleTimer];
After you get things done, remember to reset it to normal state:
[sb resetIdleTimerAndUndim:YES]; // or NO if you don't want the screen dims at once.
来源:https://stackoverflow.com/questions/17467251/how-to-prevent-auto-lock-screen-in-hooking-springboard