Android 2.1 & HTC Desire: Is there a bluetooth problem? (CorruptedStreamException)

跟風遠走 提交于 2019-12-25 02:34:41

问题


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 with the HTC Desire in combination with Bluetooth and Android 2.1 Update1?


回答1:


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




回答2:


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 !



来源:https://stackoverflow.com/questions/3353080/android-2-1-htc-desire-is-there-a-bluetooth-problem-corruptedstreamexceptio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!