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 16:52, 26 November 2007.

Como bloquear o screen saver em Java ME

From Forum Nokia Wiki

Tradução de How to block the screen saver:

Se sua aplicação não requer pressionamento de teclas constantemente, depois de algum tempo o screen saver será iniciado pelo sistema operacional automaticamente.

Para certificar-se de que a luz do display está acesa, use o método setLights antes de o screen saver ser acionado, logo chame esse método em loop, já que o screen saver não é desabilitado, apenas interrompido, ou seja, após alguns segundos ele será acionado novamente.

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
screensaver on 9500 pavanmg General Discussion 3 2004-12-01 13:34
Some basic issues with Nokia 3650 sanjg2k1 Mobile Java Media (Graphics & Sounds) 1 2003-07-02 08:35
screensaver problem with back ground pistha1 General Symbian C++ 11 2006-05-11 11:17
How to develop Screensaver for 60 series? jjump Graphics & Video & Streaming 18 2006-07-08 12:18
Nokia 3650 AND screensavers cuono General Discussion 3 2005-08-28 00:24
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX