Oct 7, 2011

Ringtone with Android-Processing

If you want to get a ring tone here you have the code:


import android.media.Ringtone;
import android.media.RingtoneManager;
import android.database.Cursor;

RingtoneManager ringManager;
Ringtone ring;
Cursor cursor;

void setup() {
  size(screenWidth, screenHeight, A2D);
  ringManager = new RingtoneManager(this);
  cursor = ringManager.getCursor();
  maxN = cursor.getCount();  
  ring = ringManager.getRingtone(0);  

int maxN;
int n = 1;

void draw() {  ;  }

void mouseReleased(){
    ring = ringManager.getRingtone(n);
    n = (n < maxN-1)? n+1 : 0;

Enjoy it.

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.