Android 2.1 & HTC Desire: Is there a bluetooth problem? (CorruptedStreamException)
I made an application that is using Android SDK 2.1. This application uses bluetooth to connect to multiple devices.
I have 3 HTC Dreams (Google G1) as test devices. The application is running really fine on them. They are rooted and Android 2.1 is running on them.
If I join with my HTC Desire (Android 2.1 Update 1), the streams that read from the bluetooth socket are always closed if there is more than 1 bluetooth connetion open. The exception that is thrown is a IOException and a CorruptedStreamException.
A similar problem is, that sometimes I can't connect with my HTC Desire to the other devices, while the connection other way round is working perfectly well.
Are there any know issues开发者_如何学JAVA with the HTC Desire in combination with Bluetooth and Android 2.1 Update1?
The Bluetooth SPP profile in HTC Desire is broken and has a buggy implementation.
http://code.google.com/p/android/issues/detail?id=8382
Cheers, Madhu
While looking for the solution of similar problem in my app, I have found this blog.
http://mobisocial.stanford.edu/news/2011/03/bluetooth-reflection-and-legacy-nfc/
It will help all those who are still looking for this problem solution on SO
The solution has become very simple now. Just include InsecureBluetooth.java in your project and change 2 lines in BluetoothChatService.java.
tmp = InsecureBluetooth.listenUsingRfcommWithServiceRecord(mAdapter, NAME, MY_UUID, true);
and
tmp = InsecureBluetooth.createRfcommSocketToServiceRecord(device, MY_UUID, true);
Thats it !
精彩评论