根據

2017-06-11 39 views
2

我創建了一個藍牙聊天RECEIVED藍牙消息開始的if語句,我想打,我想執行,如果根據

if(messageRecieved.equals("message required"){ //Action } 我不知道哪種說法是一個動作變化等上述messageRecieved REF-:https://github.com/googlesamples/android-BluetoothChat/tree/master/Application/src/main/java/com/example/android/bluetoothchat

+0

發佈您在這裏完成的代碼 – Zakir

+0

這裏是鏈接無法發送完整的代碼 - : https://github.com/googlesamples/android-BluetoothChat/tree/master/Application/src/main/java/com/example/android/bluetoothchat – Anonymous

+0

你的問題是什麼? – Zakir

回答

1

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; 
+0

會在一分鐘內讓你知道 – Anonymous

+0

我不知道用什麼來替換「readMessage」? – Anonymous

+0

,我想我應該添加.getBytes代碼 如果(readMessage.equals(「message required」)。getBytes()){ – Anonymous