Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 10:58, 28 November 2007.

How to block the screen saver

From Forum Nokia Wiki

If your application doesn't demand constant key presses, after a while the screen saver on a J2ME phone will start automatically.

To make sure that the display light is turned on, the setLights method should be called before the screen saver is started and this must be done in a loop since the screen saver is not disabled just interrupted.

import com.nokia.mid.ui.DeviceControl;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
 
public class BacklightWorkaround extends MIDlet {
 
  private SimpleCanvas canvas;
 
  /**
   * Keeps the backlight on by repeatedly setting
   */
  class LightThread extends Thread {
    public void run() {
      while(true){
       
        DeviceControl.setLights(0, 100);       
        try {
          Thread.sleep(5000);
        } catch (InterruptedException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
 
  private class SimpleCanvas extends Canvas implements CommandListener{
    private Command exitCmd;
    private MIDlet midlet;
   
    public SimpleCanvas(MIDlet midlet) {
      this.midlet = midlet;
      exitCmd = new Command("Exit",Command.EXIT, 1);
      addCommand(exitCmd);
      setCommandListener(this);
    }
    public void paint(Graphics g) {     
      g.drawString("Let there be light.", 0, 0, Graphics.LEFT|Graphics.TOP);
    }
 
    public void commandAction(Command command, Displayable displayable) {
      if(command == exitCmd){
        midlet.notifyDestroyed();
      }
    }
  }
 
  public void startApp() {
    if(canvas == null){
      canvas = new SimpleCanvas(this);
      new LightThread().start();
    }
   
    Display.getDisplay(this).setCurrent(canvas);
  }
 
  public void pauseApp() { }
 
  public void destroyApp(boolean unconditional) { }
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
how to autostart midlet when screen is idle raghda Mobile Java General 1 2007-08-30 19:45
Turn Screen Light On djorge General Symbian C++ 0 2006-07-06 14:40
Some memory related and other issues sanjg2k1 General Discussion 0 2003-07-07 17:38
Creating a 6131 readable external tag wth an external reader gngulrajani Near Field Communication 1 2008-04-03 17:47
animated 3d screensaver amichel General Browsing 1 2002-07-31 23:18
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZjavaQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX