【问题标题】:BluetoothManager.getConnectedDevices is not finding any devicesBluetoothManager.getConnectedDevices 未找到任何设备
【发布时间】:2021-06-27 00:56:52
【问题描述】:

当我在 developer.android.com 上阅读时,我正在尝试通过 BluetoothManager 类查找我连接的设备。我使用下面的行来获取已连接设备的列表:

System.out.println(bluetoothManager.getConnectedDevices(BluetoothGatt.GATT).toString());

但是,它只是返回一个空数组。我在清单文件中给了我的应用蓝牙和蓝牙管理权限,所以我认为权限没有任何问题。

我怎样才能让它工作?

【问题讨论】:

    标签: java android android-studio mobile-development


    【解决方案1】:

    试试下面的;它应该会有所帮助,因为它会尝试获取当前状态(或配置文件)为STATE_CONNECTED 的连接设备:

    System.out.println(bluetoothManager.getConnectedDevices(BluetoothProfile.STATE_CONNECTED).toString());
    

    阅读此处了解更多信息:

    https://developer.android.com/reference/android/bluetooth/BluetoothProfile

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 2019-05-06
      • 2014-10-13
      • 2015-08-29
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多