×
Namespaces

Variants
Actions
(Difference between revisions)

Como bloquear o screen saver em Java ME

From Nokia Developer Wiki
Jump to: navigation, search
thiagobrunoms (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update of Template:ArticleMetaData)
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
Tradução de [[How to block the screen saver]]:
+
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language=Lang-Portuguese
 +
|translated-by=[[User:Dcrocha]]
 +
|translated-from-title=How to block the screen saver
 +
|translated-from-id=7232
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp=<!-- After re-review: YYYYMMDD -->
 +
|update-by=<!-- After significant update: [[User:username]]-->
 +
|update-timestamp=<!-- After significant update: YYYYMMDD -->
 +
|creationdate=20071126
 +
|author=[[User:Soku123]]
 +
}}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.
 
Se sua aplicação não requer pressionamento de teclas constantemente, depois de algum tempo o screen saver será iniciado pelo sistema operacional automaticamente.
Line 67: Line 89:
 
</code>
 
</code>
  
[[Category:Java_ME_(Português)]]
+
[[Category:Java ME]]
[[Category:Exemplos de código Java ME]]
+
[[Category:Code Examples]]
[[Category:Lang-PT]]
+
[[Category:Lang-Portuguese]]
 +
<!-- Translation --> [[en:How to block the screen saver]]

Revision as of 10:07, 7 December 2011

Article Metadata

Artigo
Tradução:
Por dcrocha
Última alteração feita por hamishwillee em 07 Dec 2011
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;
 
/**
* Mantém a luz de fundo acessa (ativa em intervalos de tempos de 5000ms)
*/

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) { }
}
156 page views in the last 30 days.