App taking consderable time while loading in Android mode, but java mode is normal.

edited September 2016 in Android Mode

Code is shown below. Please help.

                        import oscP5.*;
                        import netP5.*;

                        OscMessage myMessage;
                        OscP5 oscP5tcpClient;

                        float i;
                        float a = 0.0;
                        float inc = TWO_PI/25.0;

                        void setup() {
                        size(640, 360);

                          oscP5tcpClient = new OscP5( this, "", 1234, OscP5.TCP);

                        void draw() {
                          OscMessage myMessage = new OscMessage("");
                          myMessage.add(new float[] {sin(180+sin(a)*100.0), 180+sin(a)*100.0}); /* add an int to the osc message */


                        void calcWave() {
                          for (int i = 0; i < 600; i=i+4) {
                            line(i, 180, i, 180+sin(a)*100.0);
                            a = a + inc;


  • How long is long? It is normal for Android apps to take longer to be interpreted (and loaded) that their java counterpart. It should work nevertheless, doesn't it?


  • After interpreted (and loaded), it takes 2-3 minutes to show output on phone. Meanwhile, black screen appears on phone

    Actually, Android phone is acting as client and Matlab is Server. Matlab drops the connection because phone taking too much time.

    But with java, everything is fine.

    I am working on Android mode from long time, but i have seen this problem first time.

  • Answer ✓

    Sorry I haven't seen that problem on my side. Did you update your android mode recently? What version do you have? I haven't done it yet.

    A couple of suggestions:

    Run some other android code and see if the problems persist in other sample codes

    For this code, after the apk package is loaded in the phone, you can execute it directly in your phone by clicking on it in your phone instead of running it from the processing console. In this way you could test your application and the connection to matlab. This should be a temporal solution.

    A suggestion for your code is to set your phone as the server and matlab would connect as a client. Or maybe you should look into the possibility of increasing matlab's connection timeout time. By the way, what matlab version are you using?


  • Matlab version : R2015a Android Version : 5.0

    I will do as suggested. Thank you

Sign In or Register to comment.