- Home /
I want to prevent android phone from going to sleep using my code?
I want to prevent android phone from going to sleep using my code? How to do that please help.
Answer by vfxjex · Aug 20, 2013 at 06:45 AM
try this
function Start (){
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
Answer by bluebeardit · Aug 11, 2017 at 08:01 PM
I would add that if you want to revert it to the normal state you'll have to use this: Screen.sleepTimeout = SleepTimeout.SystemSetting;
Answer by Dave 5 · Sep 20, 2010 at 02:50 PM
It appears you can set iPhoneSettings.screenCanDarken to false to achieve this at the moment.
I just built and confirmed this works. Adding that line shows the permission "System tools prevent phone from sleeping".
Answer by · Sep 16, 2010 at 04:07 AM
This has already been answered ... Android: prevent phone from sleeping
Settings/Applications/Development/Stay Awake (check that)
But I want to do it in my program itself. Please provide me the code.
yah it should be in the program so that you will not be changing the settings from time to time.