RxFit
RxFit copied to clipboard
How can I do app with real-time data using like sensors?
Hi! I have a little trouble - how can I check a real-time sensors data?
`RxFit rxfit = new RxFit( this, new Api[] { Fitness.SENSORS_API }, new Scope[] { new Scope(Scopes.FITNESS_ACTIVITY_READ), new Scope(Scopes.FITNESS_LOCATION_READ) } );
DataSourcesRequest dataSourcesRequest = new DataSourcesRequest.Builder()
.setDataTypes(DataType.TYPE_DISTANCE_DELTA)
.setDataTypes(DataType.TYPE_STEP_COUNT_DELTA)
.setDataTypes(DataType.TYPE_CALORIES_EXPENDED)
.setDataSourceTypes(DataSource.TYPE_DERIVED)
.setDataSourceTypes(DataSource.TYPE_RAW)
.build();
rxfit.sensors().findDataSources(dataSourcesRequest)
.flatMap(dataReadResult -> new Subject<FitnessSessionData>() {
@Override
public boolean hasObservers() {
return false;
}
@Override
public boolean hasThrowable() {
return false;
}
@Override
public boolean hasComplete() {
return false;
}
@Override
public Throwable getThrowable() {
return null;
}
@Override
protected void subscribeActual(Observer<? super FitnessSessionData> observer) {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(FitnessSessionData value) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
})
.subscribe(bucket -> {
Toast.makeText(MainActivity.this, bucket.distance+"", Toast.LENGTH_SHORT).show();
/* do something */
});`
I'm trying to do something like this - but I haven't go any answer. Thanks you!!!