我正在开发基于 Samsung Chord SDK 的应用程序。我需要在 sendDataToAll() 中发送视频的当前位置,它接受 byte[][] 中的数据。我的问题是,当我尝试发送类型转换为字节的当前位置(这是一个 int)时,我得到了返回的负值(以字节为单位)。当我尝试在 OnDataRecived() 中将负值转换为 int 时,它仍然是相同的负值。我该如何解决这个问题?
Sending code:
//for sending the message
int currPos = mVideoView.getCurrentPosition();
logView.append("Duration sent= " + currPos);
//Integer resume = -3;
Byte msgByte = new Byte("-3");
byte [] [] pay = new byte [1] [2];
pay[0] [0] = msgByte;
Byte msgByte2 = new Byte((byte) currPos);
logView.append("Duration sent= " + msgByte2);
pay[0] [1] = msgByte2;
mChordchannel.sendDataToAll("Integer", pay);
// im sending -3 so that im checking that the user pressed the resume .
Receiving code:
//on receiving
else if(intRec == -3) {
Byte pos = rec[0] [1];
int posn;
posn = pos.intValue();
logView.append("Duration received= " + posn);
mVideoView.seekTo(posn);
mVideoView.start();
}