Screen Bright with Android-Processing
in
Android Processing
•
2 years ago
To Set the Window(Screen) Bright in Processing for Android simply add the following code to your sketch:
- void setup(){...}
- void draw() {...}
- //www.akeric.com/blog/?p=1313
- //-----------------------------------------------------------------------------------------
- // 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() {
- super.onResume();
- setWindowBright();
- 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);
- }