Processing + Android c.write(unknown source)?

edited November 2013 in Android Mode

Hi im trying to communicate with a ip using processing on android. the sketch works on java, but when i use android mode it gets an error and wont work.

this is the error

   
processing.test.ots_processing_ledlys_prosjekt_v4_android.OTS_PROCESSING_LEDLYS_PROSJEKT_V4_Android.draw(OTS_PROCESSING_LEDLYS_PROSJEKT_V4_Android.java:84)
        at processing.core.PApplet.handleDraw(Unknown Source)
        at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
        at processing.core.PApplet.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:1019)
    java.lang.NullPointerException
        at processing.net.Client.write(Unknown Source)
        at processing.net.Client.write(Unknown Source)
        at

this is my sketch

import processing.net.*;


Client c;

 int cTimer = 1;

 String Buffer0 = "0";
 String Buffer1 = "0";
 String Buffer2 = "0";
 String Buffer3 = "0";

 String StringIP = "192.168.1.111";
 int Port = 1000;
 int B_Led0 = 0;
 int B_Led1 = 0;
 int B_Led2 = 0;
 int B_Led3 = 0;
 int Connected = 1;
 int ConnectedDelay = 0;
 int PressDelay = 0;

 int Rect1X = 50;
 int Rect1Y = 50;
 int Rect2X = 150;
 int Rect2Y = 50;
 int Rect3X = 250;
 int Rect3Y = 50;
 int Test = 0;




void setup(){
  size(640,480);
  ellipse(Rect1X, Rect1Y, 50, 50);
  ellipse(Rect2X, Rect2Y, 50, 50);
  ellipse(Rect3X, Rect3Y, 50, 50);



c = new Client(this,"192.168.1.111", 1000); 


}

void draw(){





Buffer0 = "" + B_Led0;
Buffer1 = "" + B_Led1;
Buffer2 = "" + B_Led2;
Buffer3 = "" + B_Led3;




if(cTimer >= 2){
   c.write(Buffer0 + Buffer1 + Buffer2 + Buffer3 + "\n");

   cTimer = 0;

}

if(cTimer <= 10){cTimer += 1;}
}

thanks in advance! :D

Answers

  • Answer ✓

    Android mode doesn't currently support the use of core libraries (unless that changed in 2.1? I didn't see it in the list of revisions...). Instead, you will have to resort to a contributed networking library. If I am correct, oscP5 works on Android. Of course, this will require re-writing most of your code...

Sign In or Register to comment.