Learning how to request and release the power state is a basic power management skill:
To set the power state, call the request() method with the intended power resource and its state. In this example, the SCREEN_NORMAL state is requested for the screen resource:
webapis.power.request("SCREEN", "SCREEN_NORMAL");
To release a power state, call the release() method with the intended resource:
webapis.power.release("SCREEN");
To listen to the screen state changes, use the setScreenStateChangeListener() method:
function onScreenStateChanged(previousState, changedState) { console.log("Screen state changed from" + previousState + "to" + changedState); } webapis.power.setScreenStateChangeListener(onScreenStateChanged);