蓝牙
使用 Android 平台的蓝牙功能以及向后兼容的 API。
最新更新 | 稳定版 | 候选发布版 | Beta 版 | Alpha 版 |
---|---|---|---|---|
2023 年 11 月 29 日 | - | - | - | 1.0.0-alpha02 |
声明依赖项
如需添加对蓝牙的依赖项,您必须将 Google Maven 代码库添加到您的项目中。请阅读Google 的 Maven 代码库以了解更多信息。
在您的应用或模块的 build.gradle
文件中添加所需工件的依赖项
Groovy
dependencies { implementation "androidx.bluetooth:bluetooth:1.0.0-alpha02" }
Kotlin
dependencies { implementation("androidx.bluetooth:bluetooth:1.0.0-alpha02") }
有关依赖项的更多信息,请参阅添加构建依赖项。
反馈
您的反馈有助于改进 Jetpack。如果您发现新问题或有改进此库的建议,请告诉我们。在创建新问题之前,请查看此库中的现有问题。您可以通过点击星标按钮,为您关注的现有问题投票。
有关更多信息,请参阅问题跟踪器文档。
此工件没有发布说明。
版本 1.0
版本 1.0.0-alpha02
2023 年 11 月 29 日
androidx.bluetooth:bluetooth:1.0.0-alpha02
和 androidx.bluetooth:bluetooth-testing:1.0.0-alpha02
已发布。版本 1.0.0-alpha02 包含这些提交。
新功能
- 将
minSdkVersion
降低到 21
API 变更
GattServerConnectFlow#updateServices
变为 suspend 函数 (I0237d)- 将
AdvertiseParams.durationMillis
更改为 Long (If6771) - 将
openGattServer
转换为 Flow (Icef54) - 扫描失败时抛出
ScanException
并默认将扫描器设置为setLegacy(false)
(Ib337c) - 广播失败时抛出
AdvertiseException
(I0e691) - 添加一般蓝牙异常以捕获 (I0130d)
- 将广播转换为 Flow 并更改最大持续时间 (I32fd8)
- 将
serviceData
和serviceSolicitationUuids
添加到ScanResult
(I6d7f0) - 将
durationMillis
从 Long 更改为 Duration (I89d49) - 将 rssi 和
periodicAdvertisingInterval
添加到ScanResult
(I60b51) - 将
serviceSolicitationUuid
和solicitationUuidMask
添加到ScanFilter
(Ic2206) - 添加了
GattServerSessionScope#subscribedCharacteristics
(I0edab) - 将
serviceSolicitationUuids
添加到AdvertiseParams
(Ic9aa7) - 将
AdvertiseParams.durationMillis
从 Int 更改为 Long (I6873f) GattServerSessionScope#notify
不返回值,但如果失败会抛出异常 (Ifc26f)
错误修复
- 提取扫描功能 (I4d43f)
版本 1.0.0-alpha01
2023 年 9 月 20 日
androidx.bluetooth:bluetooth:1.0.0-alpha01
和 androidx.bluetooth:bluetooth-testing:1.0.0-alpha01
已发布。版本 1.0.0-alpha01 包含这些提交。
新功能
- 这是 AndroidX 蓝牙 API 的初始版本,它提供了一个 Kotlin API 界面,涵盖了蓝牙低功耗 (Bluetooth LE) 扫描和广播,以及 GATT 客户端和服务器用例。它提供了一个最小的 API 界面,具有异步和同步操作的清晰线程模型,并确保所有方法都得到执行并提供结果。