How can I know if the data was successfully transmitted to another
device using Bluetooth? Is there a pre-made function in Bluetooth API?
I have here an edited source code sample of BluetoothChat

in my BluetoothChatService.java
------------------------------------------------
[code]
        public void write(byte[] buffer) {
                Log.e("write function service","write function triggered");
            try {
                mmOutStream.write(buffer);
                String logWriteBuf = new String(buffer);
                Log.e("write function trycatch",logWriteBuf);
                // Share the sent message back to the UI Activity
                mHandler.obtainMessage(BluetoothChat.MESSAGE_WRITE,
-1, -1, buffer)
                        .sendToTarget();
            } catch (IOException e) {
                Log.e(TAG, "Exception during write", e);
            }
        }
[/code]
------------------------------------------------------------------------------------------
and the handler will call this switch statement in BluetoothChat
------------------------------------------------------------------------------------------
            case MESSAGE_WRITE:
                Log.e("handleMessage", "- message write -");
                byte[] writeBuf = (byte[]) msg.obj;
                // construct a string from the buffer
                String writeMessage = new String(writeBuf);
                mConversationArrayAdapter.add("Me:  " + writeMessage);
                break;
-----------------------------------------------------------------------------------------------------

As far as I understand, the line

mmOutStream.write(buffer);

will send the data to the device?

PS: The only clue that I know is the device with Bluetooth will
automatically reply to the Android phone when that device received a
string-formatted data, and the device does not reply any message when
I tried to transmit the data-string in the Android phone.

Thanks in advance.
JR

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to