How to prevent auto-lock screen in hooking SpringBoard?

隐身守侯 提交于 2019-12-12 18:53:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!