Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I do app with real-time data using like sensors? #8

Open
akhorevich opened this issue Apr 22, 2018 · 0 comments
Open

How can I do app with real-time data using like sensors? #8

akhorevich opened this issue Apr 22, 2018 · 0 comments

Comments

@akhorevich
Copy link

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!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant