【问题标题】:BluetoothSocket accept() IOExceptionBluetoothSocket accept() IOException
【发布时间】:2012-01-03 23:33:36
【问题描述】:

我只在传出连接时遇到这个问题。我从示例http://developer.android.com/guide/topics/wireless/bluetooth.html 中复制了我的大部分源代码

所以我真的不知道这个问题的原因是什么......

首先是发生IOException的代码:

try {
                // This is a blocking call and will only return on a
                // successful connection or an exception
                socket = mmServerSocket.accept();
            } catch (IOException e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed", e);
                break;
            }

每次我将手机连接到平板电脑时,accept() 都会在手机上引发 IOException:

BluetoothChatService 套接字类型:nullaccept() 失败 BluetoothChatService java.io.IOException:操作已取消

我相信这在某种程度上与此博客中描述的问题有关: http://www.androiddiscuss.com/1-android-discuss/86844.html

顺便说一下,BluetoothConnection 运作良好,但我的手机无法接收任何数据。

编辑:我刚刚意识到从我的 Galaxy S 到我的摩托罗拉 Xoom 的蓝牙连接无法与市场上其他流行的蓝牙应用程序建立......

如果我反过来连接,从我的平板电脑到我的手机,平板电脑就会完全重启。

【问题讨论】:

  • 您能否粘贴堆栈跟踪,以便我们查看发生了什么。也许一端过早地关闭了连接

标签: java android bluetooth


【解决方案1】:

这可能是身份验证问题。您的设备是否已配对?

【讨论】:

  • 是的。它们是配对的,或者它在首选项中显示。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 1970-01-01
  • 1970-01-01
  • 2012-12-09
  • 2012-09-03
  • 2015-04-17
相关资源
最近更新 更多