Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

onLocationChanged is called from a LocationRequest of another fragment #142

Closed
westnordost opened this issue Nov 27, 2016 · 1 comment
Closed
Assignees

Comments

@westnordost
Copy link
Contributor

westnordost commented Nov 27, 2016

Description

Not sure if this is expected behavior (=mirroring google play api) or a bug. In any case, it would be good if this was documented:
Requesting different location updates from different places will make the onLocationChanged method be called in both places whenever the condition of either location request of any of the two places is fulfilled.

Steps to Reproduce

I have an activity which requests location updates only every few minutes and only if the user moved quite a bit.

LocationRequest request = LocationRequest.create()
		.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
		.setSmallestDisplacement(500)
		.setInterval(3*60*1000); // 3 minutes

LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);

Then, I also got a fragment, which creates an own lostApiClient for itself (which I guess points to the same object internally) and requests very frequent location updates, let's say every second.

As soon as that fragment starts requesting location updates, the former mentioned activity starts to get calls every second to onLocationChanged.
The activity is doing an expensive operation on onLocationChanged, I expected that the parameters of my location request would be respected.

Lost & Android Version

2.1.1 on Android 5.0

@sarahsnow1 sarahsnow1 self-assigned this Dec 1, 2016
@sarahsnow1
Copy link
Contributor

Thank you for the detailed report! The behavior you are observing is a bug and should be updated to do as you suggest and respect the parameters of the location request. This will also bring it up to par with Play Services. Stay tuned for a fix coming soon...

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

No branches or pull requests

3 participants