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

getDetectedActivity is only getting called once. #186

Open
aalap03 opened this issue Apr 25, 2018 · 0 comments
Open

getDetectedActivity is only getting called once. #186

aalap03 opened this issue Apr 25, 2018 · 0 comments

Comments

@aalap03
Copy link

aalap03 commented Apr 25, 2018

This is my code to post location to server with two filters

  1. if my device is not still and
  2. if it has accuracy less than 40

With delay parameter in detectedActivity Observable as 0 and my LocationRequest Interval is also 5 secs.I expect logs in zip method frequently (and not in the onNext or onError as my device is still) but I only see log with test zip once. If I have understood it wrong please correct me or please let me know where I have made mistake in my code below.

   long INTERVAL = 1000*5;
   locationRequest = LocationRequest
            .create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setInterval(INTERVAL)
            .setFastestInterval(INTERVAL);

   Observable<Location> updatedLocation = provider.getUpdatedLocation(locationRequest);
   Observable<ActivityRecognitionResult> detectedActivity = provider.getDetectedActivity(0);

    compositeDisposable.add(
            Observable.zip(updatedLocation, detectedActivity, (location, result) -> {
                isDeviceMoving = result.getMostProbableActivity().getType() != DetectedActivity.STILL;
                Log.d(TAG, "test: zip moving ? " + isDeviceMoving);
                return location;
            })
                    .filter(location -> isDeviceMoving)
                    .filter(location -> location.getAccuracy() <= 40)
                    .subscribe(location -> Log.d(TAG, "test: " + location)
                            , throwable -> Log.d(TAG, "test: er " + throwable.getLocalizedMessage())));
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