我試圖使用Android的樣本BlueToothChat每次但有件事我不明白:的getBytes的toString不會產生相同的結果
byte[] send = message.getBytes();
Log.d("SEND_BYTE", send.toString());
mChatService.write(send);
這裏,消息是一個字符串,然後轉換爲字節,我想爲了被髮送。但是當我檢查日誌時,即使我輸入的消息很長,send.toString()
部分也非常短。更糟糕的是,如果我輸入兩次相同的信息,我會得到2個不同的日誌,我發現這很奇怪。 下面是我得到的日誌中的消息hello
,連續三次:
[[email protected]
[[email protected]
[[email protected]
一定有什麼東西(也許很簡單的),我沒有得到,但可以(T弄清楚什麼是你能不能幫我這個
編輯:? 也許是有用的添加代碼的下面,所以在這裏是完整的代碼:
byte[] send = message.getBytes();
Log.d("SEND_BYTE", send.toString());
mChatService.write(send);
// Reset out string buffer to zero and clear the edit text field (buffer is used in the write function)
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
默認的toString方法返回的getClass()的getName()+ '@' + Integer.toHexString(hashCode()方法) – 2013-03-14 10:55:09