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.
The Bluetooth GATT (Generic Attribute Profile) is the foundation for the design of any BLE system and defines the way a smartphone application (or any central device) interacts with the end device (the peripheral device).
A GATT Client is a device which accesses data on a remote GATT Server, paired via BLE, using read, write, notify, or indicate operations. Once two devices are paired each device can act as both a GATT Server and a GATT Client.
To find BLE devices, you use the startScan() method. This method takes a ScanCallback as a parameter. You must implement this callback, because that is how scan results are returned.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With