I want to prevent android phone from going to sleep using my code? How to do that please help.
try this
function Start (){
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
I would add that if you want to revert it to the normal state you’ll have to use this: Screen.sleepTimeout = SleepTimeout.SystemSetting;
It appears you can set iPhoneSettings.screenCanDarken to false to achieve this at the moment.
This has already been answered ... Android: prevent phone from sleeping
Settings/Applications/Development/Stay Awake (check that)