根据消息 RECEIVED-Bluetooth 启动 if 语句

Start an if statement according to the message RECEIVED-Bluetooth

我创建了一个蓝牙聊天,我想进行更改,以便在

if(messageRecieved.equals("message required"){ //Action } 不知道上面说的messageRecieved是哪个语句 参考:https://github.com/googlesamples/android-BluetoothChat/tree/master/Application/src/main/java/com/example/android/bluetoothchat

BluetoothChatFragment.java 中,在 handleMessage(Message msg) 中添加您的逻辑,其中 UI 片段从服务接收消息:-

case Constants.MESSAGE_READ:
    byte[] readBuf = (byte[]) msg.obj;
    // construct a string from the valid bytes in the buffer
    String readMessage = new String(readBuf, 0, msg.arg1);
    if(readMessage.equals("message required")){
        mConversationArrayAdapter.add(mConnectedDeviceName + ":  " + readMessage);
    }
    break;