【问题标题】:How to detect Bluetooth version on Android?如何在Android上检测蓝牙版本?
【发布时间】:2012-07-07 02:11:06
【问题描述】:

我目前正在开发 BLE 应用程序,我想过滤发现的设备并在列表中仅保留 BLE 兼容的设备。

使用 Broadcom API 很容易确定设备是否为 BLE。 不幸的是,DROID RAZR 不提供 Broadcom 库,所以我不得不使用摩托罗拉 BLE 库......毫无疑问,他们没有检查蓝牙版本的方法。

我阅读了所有可能的原生 Android 蓝牙类,但没有找到与我相关的信息(我找到了类别 - 电脑、智能手机等,但没有版本。)

有人知道如何查看扫描设备的蓝牙版本吗?

【问题讨论】:

  • 您是否尝试过导入 Broadcom API?
  • 正如我所说。我无法在手机上使用 Broadcom API。它在模拟器上运行良好,但如果我希望它在手机上,我需要使用 uses-library,这是不允许的(通过 android)。所以我不得不使用他们原生的摩托罗拉 API

标签: android bluetooth-lowenergy


【解决方案1】:

当你发现设备时,如果你能得到蓝牙设备的android.bluetooth.BluetoothDevice,也许你可以使用Android官方的Api BluetoothDevice.getType()来过滤经典或BLE设备。

/**
 * Get the Bluetooth device type of the remote device.
 *
 * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
 *
 * @return the device type {@link #DEVICE_TYPE_CLASSIC}, {@link #DEVICE_TYPE_LE}
 *                         {@link #DEVICE_TYPE_DUAL}.
 *         {@link #DEVICE_TYPE_UNKNOWN} if it's not available
 */
public int getType() {
    if (sService == null) {
        Log.e(TAG, "BT not enabled. Cannot get Remote Device type");
        return DEVICE_TYPE_UNKNOWN;
    }
    try {
        return sService.getRemoteType(this);
    } catch (RemoteException e) {Log.e(TAG, "", e);}
    return DEVICE_TYPE_UNKNOWN;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    相关资源
    最近更新 更多