I want to make sensor request to my mi band 2 from my app real time. I have some difficulties with this. I use permissions BLUETOOTH
and BLUETOOTH_ADMIN
. I checked that I can see my device via bluetooth le default api. I try to use this example https://developers.google.com/fit/android/ble-sensors?hl=ru and all the time I get onScanStopped and this callback dont have some explanation, so I dont understand why it failes. My code:
GoogleApiClient client = new GoogleApiClient.Builder(this)
.addApi(Fitness.SENSORS_API)
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ))
.addScope(new Scope(Scopes.FITNESS_BODY_READ))
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
client.connect();
And onConnected I have:
Fitness.getBleClient(this, GoogleSignIn.getLastSignedInAccount(this))
.startBleScan(Arrays.asList(DataType.TYPE_ACTIVITY_SEGMENT), 60, bleScanCallbacks)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Log.d("TAG_F", "onComplete: " + task.isSuccessful());
}
});
Here I also tries all of this data types DataType.TYPE_STEP_COUNT_DELTA, DataType.TYPE_HEART_RATE_BPM
This shows me that my scan is successful. But on callback after 60 seconds I get onScanStopped
:
private BleScanCallback bleScanCallbacks = new BleScanCallback() {
@Override
public void onDeviceFound(BleDevice bleDevice) {
Log.d("TAG_F", "onDeviceFound: " + bleDevice.getDataTypes());
}
@Override
public void onScanStopped() {
Log.d("TAG_F", "onScanStopped: ");
}
};
from Fitness startBleScan successful but scan Stopped with MI Band 2
No comments:
Post a Comment