Oct 4, 2011

Set Window (Screen) Bright in Processing-Android

To Set the Window Bright in Processing for Android simply add the following code to your sketch:

void setup(){...}
void draw() {...}


// Override the parent (super) Activity class:
// States onCreate(), onStart(), and onStop() aren't called by the sketch.  Processing is entered at
// the 'onResume()' state, and exits at the 'onPause()' state, so just override them:

void onResume() {


  println("RESUMED! (Sketch Entered...)");

import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

void setWindowBright(){
  getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_TURN_SCREEN_ON);

// to set a diferent bright level (other than default)
//  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();   
//  layoutParams.screenBrightness = 0.8f;                    
//  getWindow().setAttributes(layoutParams);

That's all.