如何弹出从​​谷歌启用蓝牙提示播放服务?蓝牙、弹出、提示

2023-09-07 22:16:35 作者:王位之上

应用程序同时使用位置和BLE,如果位置或蓝牙将被禁用我要问用户,使他们。

Application I'm working on uses both Locations and BLE and if location or bluetooth are disabled I have to ask user to enable them.

最新谷歌播放服务提供了一个标准的方式来做到这一点使用 LocationSettingsRequest 它检查的要求,如果需要设置的更改提高标准弹出。它的工作原理就像一个魅力单独的位置,但一旦我添加 SetNeedBle(真) LocationSettingsRequest 我得到一个状态 SETTINGS_CHANGE_UNAVAILABLE

Latest Google Play Services provides a standard way to do that using LocationSettingsRequest which checks requirements and raises standard popup if changes to settings are required. It works like a charm for location alone but once I add SetNeedBle (true) to LocationSettingsRequest I get a status SETTINGS_CHANGE_UNAVAILABLE.

只有我的猜测是我需要添加 AddApi(FitnessClass.BLE_API)打电话到 GoogleApiClientBuilder ,因为它可能是BLE的功能是至关重要的,但后来我得到了连接到谷歌播放服务与 SIGN_IN_REQUIRED 失败状态这是令人困惑,因为我只需要健身服务BLE一部分。

The only my guess was I need to add AddApi (FitnessClass.BLE_API) call to a GoogleApiClientBuilder as it might be vital for BLE functionality, but then I got connection to Google Play Services failed with SIGN_IN_REQUIRED status which is confusing as I just need BLE part of Fitness service.

有谁知道 LocationSettingsRequest 用法的好例子来提示用户输入两个地点和蓝牙?

Does anyone know good example of LocationSettingsRequest usage to prompt user for both locations and bluetooth?

推荐答案

看起来像它已被固定在8.1.0所以 SetNeedBle(真)按预期工作:

Look like it has been fixed in 8.1.0 so SetNeedBle (true) works as expected: