简体   繁体   中英

How to find out if Android device supports Bluetooth Low Energy

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?

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"/>

The important code is :

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

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

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"

That code works for me.

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

You are supposed to check for the 'feature':

PackageManager pm = ctx.getPackageManager();
boolean hasBLE = pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);

I'm not really sure how seriously the manufacturers take this though - the only feature I've checked myself is FEATURE_TELEPHONY and different manufacturers handle it in different (and puzzling) ways, so your mileage may vary, but I do believe that this is the way you are intended to do it.

The Android Bluetooth architecture completely changed from Android 4.1 to 4.2. Any device with Android Jelly Bean 4.2 or later can not support Bluetooth Low Energy because it's not available in the new Bluedroid stack. See:

http://events.linuxfoundation.org/images/stories/slides/abs2013_rymanowski.pdf

You have correctly provided the code to check if a supports device has BLE. That check sees if there is the feature android.hardware.bluetooth_le which is usually stored in a file named android.hardware.bluetooth_le.xml at the location /system/etc/permissions which you can manually navigate to with a file manager in the Android device.

Actually the N7 2012 does have the hardware support for BLE but Google's rom does not support it. I have a N72012 with the purity Rom installed and can confirm that it can connect to BLE devices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM