-1

我正在开发基于 Samsung Chord SDK 的应用程序。我需要在 中发送视频的当前位置sendDataToAll(),它接受 中的数据byte[][]。我的问题是,当我尝试将int类型转换为 的当前位置(这是一个 )发送时byte,我得到了返回的负值(in byte)。当我尝试将负值转换为intin 时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();
}  
4

1 回答 1

0

您在这些语句中将类型 Byte 转换为 byte

    pay[0] [0] = msgByte;
    pay[0] [1] = msgByte2;

试试这个而不是上面的

   pay[0] [0] = msgByte.byteValue();
   pay[0] [1] = msgByte2.byteValue();

这就是我假设的问题的原因。

于 2014-05-05T11:53:37.887 回答