Android, OSC, receiver not receiving messages.

569 Views Asked by At

I am working on an app that receive message from other program via OSC. The library I used is the JavaOSC from http://www.illposed.com/software/javaosc.html.

I put the following in the onCreate method (the try{} part):

import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage;
import com.illposed.osc.OSCPort;
import com.illposed.osc.OSCPortIn;

public class MainActivity extends AppCompatActivity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            OSCPortIn receiver = new OSCPortIn(5679);
            OSCListener listener = new OSCListener() {
                public void acceptMessage(Date time, OSCMessage message) {
                    System.out.println("Message received!");
                }
            };
            receiver.addListener("/fromPython", listener);
            receiver.startListening();
        } catch (SocketException e) {
            Log.d("OSCSendInitalisation", "Socket exception error!");
        }
    }    
}

In my python code, I send out a message with the address of /fromPython to the right port, which I tested with other programs (e.g Max, Pd) and confirm message can be received. However, I could not receive any message here. Please help.

1

There are 1 best solutions below

0
On

Actually, there is nothing wrong with the code. It is that the Android Emulator has a different IP address than the computer. So to send message to the Emulator, you need to find out the ip of that first. Thanks.