0

我在通过 BT 接收从 SPP BT 模块发送的数据时遇到问题。当我从终端发送字节时,我得到了无意义的字符 - 例如“[B@420e98d8”。处理程序中有一部分代码负责数据接收:

        mHandler = new Handler(){
        public void handleMessage(android.os.Message msg){
            if(msg.what == MESSAGE_READ){
                try {
                    byte[] readBuf = (byte[]) msg.obj;
                    byte[] bytes = (msg.obj).toString().getBytes();

                    mReadBuffer.setText(readBuf.toString());
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

            }

            if(msg.what == CONNECTING_STATUS){
                if(msg.arg1 == 1)
                    mBluetoothStatus.setText("Connected to Device: " + (String)(msg.obj));
                else
                    mBluetoothStatus.setText("Connection Failed");
            }
        }
    };

我应该如何转换接收到的值以正确显示它们?或者如何接收这个?我不需要使用 BLE,普通蓝牙模块,在 Android Studio 2.2.3 中编程。

4

0 回答 0