gpt4 book ai didi

java - Android、OSC、接收器未接收消息。

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:16 26 4
gpt4 key购买 nike

我正在开发一个通过 OSC 从其他程序接收消息的应用程序。我使用的库是 http://www.illposed.com/software/javaosc.html 中的 JavaOSC .

我将以下内容放入 onCreate 方法(try{} 部分):

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!");
}
}
}

在我的 python 代码中,我向正确的端口发送了一条地址为/fromPython 的消息,我使用其他程序(例如 Max、Pd)对其进行了测试,并确认可以接收消息。然而,我在这里收不到任何消息。请帮忙。

最佳答案

其实代码并没有什么问题。这是Android模拟器的IP地址与计算机不同。因此,要向模拟器发送消息,您需要首先找出模拟器的 IP。谢谢。

关于java - Android、OSC、接收器未接收消息。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38922588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com