【问题标题】:java.io.IOException: [JSR82] while connecting to a bluetooth devicejava.io.IOException: [JSR82] 连接蓝牙设备时
【发布时间】:2014-06-16 21:09:42
【问题描述】:

我是安卓开发新手。我想使用蓝牙发送数据,但出现以下异常。

Connecting To Bluetooth Failed.
java.io.IOException: [JSR82] connect: Connection is not created (failed or aborted).
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:397)
odacPkg.odac.BluetoothCommunication.run(CommunicationActivity.java:493)

以下是我的源代码。

        final UUID applicationUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
        btDevice=bluetoothAdapterObj.getRemoteDevice(deviceMAC.toUpperCase());
        try {               
            BluetoothSocket btSocket = btDevice.createRfcommSocketToServiceRecord(applicationUUID);
            btSocket.connect();
            OutputStream outStream = btSocket.getOutputStream();
            outStream.write(sendData);
            btSocket.wait(CommunicationActivity.PACK_TIMEOUT);
            InputStream inStream = btSocket.getInputStream();
            inStream.read(receiveData);
            outStream.flush();
            outStream.close();
            outStream.close();
        }   
        catch (Exception e) {

        }

【问题讨论】:

  • 你添加了吗?
  • @PadmaKumar 是的,我做到了。
  • @HariBabuMandala - 你能解决这个问题吗?我在连接到远程设备时也遇到了类似的问题。

标签: android bluetooth


【解决方案1】:

这不是来自您的代码的问题,我只需重新启动 android 设备即可解决。我猜android设备的操作系统有些奇怪,至少对于4.1版的果冻豆。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 2016-07-08
    • 2020-01-27
    • 2016-03-13
    相关资源
    最近更新 更多