Reputation: 121
In android, I have used BLE both mode as Peripheral and Client. But I want to check isBLeGattClientSupported()
As we know some devices in android are not capable to act as BLE Gatt Client so jut wants to throw an exception that such device is not able to act as client.
I have the rest of the past for BLE my code is working fine for both mode, but stuck when I said to my device to act as a client and that device is not capable to act as the client.
Upvotes: 5
Views: 730
Reputation: 31
All android devices that have a bluetooth chip (4.0 and above) running Android 4.3 above supports BLE and all these devices supports acting as a BluetoothGatt client as well as a BluetoothGattServer as mentioned in the documentation.
Upvotes: 0
Reputation: 2842
This is straight from the android developer guide -
at run-time you can determine BLE availability by using PackageManager.hasSystemFeature():
The java example provided (a Kotlin example is also on the same page) to check the same is as follows -
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
finish();
}
This way you can check if your device supports BLE and throw an exception as required
Upvotes: 2