gpt4 book ai didi

android - 在 Android 手机上启动 GATT 服务器。需要哪个 minSdk?

转载 作者:太空狗 更新时间:2023-10-29 13:44:46 28 4
gpt4 key购买 nike

我要在我的手机上启动 GATT 服务器,以便将一些数据共享到附近的设备。来自 official documentation Android 4.3(18 API 级别)中引入了用于使用 LE 蓝牙的 API。

我发现了一些展示如何运行服务器的样本。他们都使用BluetoothLeAdvertiser这是在 Android 5.0(21 API 级别)中添加的。

因此,我构建了两个客户端/服务器示例应用程序,并且很容易在“CLIENT DEVICE”中找到了我的“SERVER DEVICE”,但是如果没有,我该如何实现呢? BluetoothLeAdvertiser?换句话说,我如何连接到 BluetoothGattServer并且不使用 BluetoothLeAdvertiser?这对我来说很重要,因为我的应用程序有 minSdk=19(Android 4.4)。

感谢您的帮助!

最佳答案

即使 Android API 级别 18 支持低功耗蓝牙,您也无法在 API 级别低于 21 的外围设备模式下使用 Android 手机。

Android Lolipop release notes 所示:

Android 4.3 introduced platform support for Bluetooth Low Energy (Bluetooth LE) in the central role. In Android 5.0, an Android device can now act as a Bluetooth LE peripheral device.

此外,并非所有具有 Lollipop 的 Android 设备都支持外设模式。 This list显示哪些设备模型能够作为服务器传输。

您可以将您的应用程序用作客户端,Android Bluetooth Low Energy documentation page 中有一个代码示例.

关于android - 在 Android 手机上启动 GATT 服务器。需要哪个 minSdk?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56381157/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com