我正在开发基于 Samsung Chord SDK 的应用程序。我需要在 中发送视频的当前位置sendDataToAll()
,它接受 中的数据byte[][]
。我的问题是,当我尝试将int
类型转换为 的当前位置(这是一个 )发送时byte
,我得到了返回的负值(in byte
)。当我尝试将负值转换为int
in 时OnDataRecived()
,它仍然是相同的负值。我该如何解决这个问题?
发送代码:
//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 .
接收代码:
//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();
}