Find Data Source Using Sensor API
ankit-geeky opened this issue · 1 comments
I am using the below code to find data sources because I am interested in reading data specifically from the sensor on a wearable device but not from the same type of sensor on the phone.
private fun findDataSource(){
Fitness.getSensorsClient(this, getGoogleAccount()).findDataSources(
DataSourcesRequest.Builder()
.setDataTypes(DataType.TYPE_LOCATION_SAMPLE)
.setDataSourceTypes(DataSource.TYPE_RAW)
.build())
.addOnSuccessListener { dataSources ->
/**
* Only my mobile phone was found as a data source
* Missing android watch
*/
for (dataSource in dataSources) {
Log.i(TAG,"Data source found: $dataSource")
Log.i(TAG,"Data Source type: ${dataSource.dataType.name}")
if (dataSource.dataType == DataType.TYPE_HEART_RATE_BPM && dataPointListener == null) {
Log.i(TAG,"Data source for TYPE_HEART_RATE_BPM found!")
registerFitnessDataListener(dataSource, dataSource.dataType)
}
}
if (dataSources != null && dataSources.size == 0){
Log.i(TAG,"No data source found")
}
}
.addOnFailureListener { e -> Log.e(TAG,"failed",e) }
}
But from the above code
* Only my mobile phone was found as a data source
* Missing android watch
NOTE: Using Polar Unite Fitness Watch