From S60 3rd Edition FP 2 onwards, and in several S60 3rd Edition FP 1 devices, the screen saver can be disabled. In normal use, the screen saver goes on automatically if there are no key presses within a certain timeframe (set as 5 seconds by default in S60 devices). This can be prevented by setting the display light using the Nokia UI API.
Calling DeviceControl.setLights
method resets inactivity
timer of the device and when it is called in a loop, it prevents the activation
of the screen saver.
The Screen saver timeout value is configurable but it can not be accessed using Java, so a hard coded value is used in the example loop.
class DisableScreenSaver extends Thread { public void run() { while(true){ DeviceControl.setLights(0, 100); try { Thread.sleep(4000); // min. screen saver timeout in UI is 5secs } catch (InterruptedException e) { } } } } public class MyMidlet extends MIDlet { public void startApp() { new DisableScreenSaver().start(); … } … }
Note that forcing the display to be constantly turned on consumes more battery. To take this into account, a MIDlet can disable screen saver only while on foreground, for example.
In devices that support Nokia UI API 1.4 or later, the screen saver
can be disabled using the method DeviceControl.resetUserInactivityTime()
for
resetting all user inactivity timers.
class DisableScreenSaver extends Thread { public void run() { while(true){ DeviceControl.resetUserInactivityTime(); try { Thread.sleep(4000); // min. screen saver timeout in UI is 5secs } catch (InterruptedException e) { } } } } public class MyMidlet extends MIDlet { public void startApp() { new DisableScreenSaver().start(); … } … }