I want to connect Mi Band 3 with my application through Google Fit SDK. I am facing issue to connect band through bluetooh. as given in Offical Google Fit Documentation - BLE Sensor I am using following code in Kotlin
var bleScanCallbacks: BleScanCallback = object : BleScanCallback() {
override fun onDeviceFound(device: BleDevice?) {
// A device that provides the requested data types is available
}
override fun onScanStopped() {
// The scan timed out or was interrupted
}
}
var response: Task<Void> = Fitness.getBleClient(
this,
GoogleSignIn.getLastSignedInAccount(this)!!
)
.startBleScan(
Arrays.asList(DataType.TYPE_STEP_COUNT_DELTA),
1000, bleScanCallbacks
)
but it showing that
'getBleClient(Activity, GoogleSignInAccount): BleClient!' is deprecated. Deprecated in Java
and
'BleScanCallback' is deprecated. Deprecated in Java
It suggesting to use BluetoothManager. I am beginner in android development. Java solution will also work.
After the BLE scanner has found your device, you can connect to its GATT server.
To connect to a GATT server on a BLE device, you use the
connectGatt()
method. This method takes three parameters: aContext
object,autoConnect
(boolean indicating whether to automatically connect to the BLE device as soon as it becomes available), and a reference to aBluetoothGattCallback
:This connects to the GATT server hosted by the BLE device, and returns a BluetoothGatt instance, which you can then use to conduct GATT client operations such as discovering services, reading and writing on BLE characteristics.
For a
BluetoothGattCallback
sample code and other infos: https://developer.android.com/guide/topics/connectivity/bluetooth-le