程序代码片段如下:
private void sendMessage(String message) {
// Check that we"re actually connected before trying anything
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
return;
}
// Check that there"s actually something to send
if (message.length() > 0) {
// Get the message bytes and tell the BluetoothChatService to write
byte[] send = message.getBytes("GBK"); /*************error**************/
mChatService.write(send);
// Reset out string buffer to zero and clear the edit text field
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
}
}
byte[] send = message.getBytes(“GBK”); 这一句报错;
原来是不带参数,这样子发出去的内容出错,大于0x7F的都发的不对,猜想是编码格式的问题,可是这个参数该怎么填呢,像上面这样写总是报错误。求指导!