如何确定 Android 设备是否支持低功耗蓝牙 [英] How to find out if Android device supports Bluetooth Low Energy

查看:73
本文介绍了如何确定 Android 设备是否支持低功耗蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎 Nexus 7 第一代不支持低功耗蓝牙,至少当我完全按照教程中的步骤操作时

It seems Nexus 7 first generation doesn't support Bluetooth Low Energy, at least when I follow exactly steps from tutorial

http://developer.android.com/guide/topics/connectivity/bluetooth-le.html

我确实在以下代码上完成了应用程序:

I do have app finish on following code:

 if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
    Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
    finish();
}

我确实检查过,启用了蓝牙.

Sure I checked, that Bluetooth enabled.

那么问题来了,如何确定设备是否支持蓝牙低功耗标准?

So the question is, how to find out for sure, if the device supports Bluetooth Low Energy standard?

更新:我使用的是 android 4.3

UPDATE: I'm using android 4.3

推荐答案

你的代码真的很好,但是您是否准确添加了以下代码?

Your code is really good, But do you add the following code exactly?

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

重要的代码是:

<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>

因为我们需要确保应用程序能够成功运行,

Because we need to make sure the application can run succesfully,

但是,如果您想让您的应用程序可用于不支持 BLE 的设备,您仍应在应用程序的清单中包含此元素,但设置 required="false"

However, if you want to make your app available to devices that don't support BLE, you should still include this element in your app's manifest, but set required="false"

该代码对我有用.

我发现了一些关于哪些设备与 BLE 功能兼容

I found something good for you about which devices be compatible with BLE feature

这篇关于如何确定 Android 设备是否支持低功耗蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆