Loading...
Logo
Processing Forum
Hello, I'm developing a game, that is controled by tilting the screen, after some time of playing, the screen goes black. (Or whatever is set in options.) Is it possible to adjust the backlight by some code so that is never goes dark? :)

Replies(7)

Copy code
  1. import android.view.WindowManager;
  2. import android.view.View;
  3. void onCreate(Bundle bundle) 
  4. {
  5.   super.onCreate(bundle);
  6.   // fix so screen doesn't go to sleep when app is active
  7.   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  8. }
What that "bundle" should be? (I don't have the class.)

I tried to use the line

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

in resume() but it didn't work.

Can you explain it more?
Sorry I forgot the Bundle import. Not sure if you need any others, but give this a go. Just add the onCreate method to your sketch, it only runs once when your application loads up.

Copy code
  1. import android.view.WindowManager;
  2. import android.view.View;
  3. import android.os.Bundle;

  4. void onCreate(Bundle bundle) 
  5. {
  6.   super.onCreate(bundle);
  7.   // fix so screen doesn't go to sleep when app is active
  8.   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  9. }


great information,

thank you


hi martiinko,

I just love your picture.

Where is it from, pease?

Greetings, Chrisir


A Disney movie... http://disney.wikia.com/wiki/Pascal (Google Image Search)
Umm... wouldn't this be a better private message?