How to get location update for every 1000 meter,ie update only if am moving ,with fused api integration.
Asked
Active
Viewed 1,317 times
2
-
Why you need it? Is there a way your location changes without moving? Like you use teleporting system? (Joking) (: – Sina R. Feb 07 '16 at 03:35
-
2Couldn't you simply cache the previous location, and perform an action when the current location is 1km away from the previous? – Dmitry Brant Feb 07 '16 at 03:38
-
Yes Dmitry is right like u have a variable name a_location_that_I_will_concider or name it altiwc then check if new location has enough distance to be replaced with altiwc or not and if yes just set it as new altiwc. Then you will use altiwc as a location – Sina R. Feb 07 '16 at 03:48
-
the scenario is that , if we are not moving no need to send my current location. the way is we can compare 2 latttiude and longitude and find distance , if distance greater than 1 km ,then upload to server. – jobi mg Feb 07 '16 at 09:00
1 Answers
3
When you are building your LocationRequest
to be used by the FusedLocationApi
you can use the method setSmallestDisplacement(...)
as specified in the documentation like below:
locationRequest.setSmallestDisplacement(1000);
Note that the argument is in meters.

George Mulligan
- 11,813
- 6
- 37
- 50