Samsung Electronics logo

Managing the Power Resource



Learning how to request and release the power state is a basic power management skill:

  1. 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");
  2. To release a power state, call the release() method with the intended resource:

    webapis.power.release("SCREEN");
    
  3. 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);