This post is a part 7 of Intel XDK Complete Tutorial post series.
With just one line of code we can prevent device from sleeping. It doesn’t matter if the device is plugged in or not.
intel.xdk.device.managePower(true,false);
If you want to prevent the device from sleeping only if the device is plugged in then use this code
intel.xdk.device.managePower(true,true);
This function only works inside event handlers. So you can’t just call it whenever you like to. For example:
document.addEventListener("intel.xdk.device.ready",function(){
intel.xdk.device.managePower(true,true);
},false);
intel.xdk.device.managePower(true,true);
},false);
Make sure you have also added Intel XDK Device plugin in your app.
If you press the power button in that case it will go to sleep.
Leave a Reply