我正忙着开发一个Android应用程序,用户可以在这里看到2017年F1个人电脑游戏的游戏中的数据。我能够设置一个UDP接收器来接收来自游戏的数据,但是输出看起来是编码的。
如何解析下面URL上列出的数据?
我使用以下URL:http://forums.codemasters.com/discussion/53139/f1-2017-d-box-and-udp-output-specification
这是我的接收代码:
class GetUDPData extends AsyncTask<Void, byte[], Void> {
int UDPPort = 20777;
Context context;
TextView tvLog;
public GetUDPData(Context context_) {
context = context_;
tvLog = (TextView) ((Activity) context).findViewById(R.id.tvLog);
}
@Override
protected void onProgressUpdate(byte[]... values) {
if (!isCancelled()) {
new ParseUDPData(context, values[0]);
}
super.onProgressUpdate(values);
}
@Override
protected Void doInBackground(Void... params) {
try {
DatagramSocket socket = new DatagramSocket(UDPPort);
byte[] receiveData = new byte[1289];
while (!isCancelled()) {
DatagramPacket packet = new DatagramPacket(receiveData, receiveData.length);
socket.receive(packet);
publishProgress(packet.getData());
}
} catch (Exception e) {
Log.d("UDP - ERROR", e.toString());
}
return null;
}
@Override
protected void onPreExecute() {
tvLog.append("Listening on IP: " + Utils.getIPAddress(true) + " and Port: " + UDPPort);
super.onPreExecute();
}
发布于 2018-08-07 13:24:31
字符串编码是什么样子的?贴一张截图看看
https://stackoverflow.com/questions/-100001981
复制相似问题