Closed mehrshadpezeshk closed 1 year ago
Hi! Thanks for the issue.
A couple more questions: What model phone / tablet are you testing this on?
When you were testing, was the device in motion? Or was it just sitting on a desk?
thanks for your response device is samsung galaxy j1 and htc desire 660 and no devices is not in motion
Thanks for the clarification. This is working as intended. If the device is not in motion, the underlying AOSP LocationManager will not always return a location at the interval requested in order to conserve power. This is also surfaced in Google's own LocationRequest
implementation here:
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setInterval(long)
This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval). The fastest rate that that you will receive updates can be controlled with setFastestInterval(long). By default this fastest rate is 6x the interval frequency.
You can play with the settings a bit to help with this. For example, setting displacement
to 0 means you'll receive all location updates - this can be very erratic across devices. I would recommend at least a small value like 0.3
to filter out the erratic behavior, but again you will need to see how this behaves on your users devices.
Also if you only want to receive location updates at 5 second intervals, you probably want setFastestInterval(5)
. Also I see the code you linked has setInterval(10)
listed - which means you'll receive location updates approximately every 10 seconds, not 5.
thanks I want to geolocate user even if user is not moving. and it's ok if getting location have delay. but my problem is when I'm using Lost this delay is too much although the Google Api Client has less delay than Lost. is there anyway to reduce this delay ?
You might try setting a lower interval: 3 seconds instead of 5. We haven't seen much difference in our testing of LOST vs Google's implementation, but then again we don't have either of those devices you mentioned available to us to test on :(
One thing we haven't had a chance to implement yet is setMaxWaitTime()
which might help with this particular issue.
An alternative could be using the Android JobScheduler
(or the older AlarmManager
if you need to support 4.x) to create a repeating task to just pull the last known location from LOST every 5 seconds. It's obviously a little more dirty but could solve the problem you're having.
same problem here. although the interval is 3 seconds I'm getting location every 20 seconds and it's weird. this result including when device is in motion
@ahm-hossein same problem when device is in motion? or stationary?
In general, we can't guarantee results be returned at a similar pace as Google's implementation, especially when stationary. While we provide a nearly identical API, the implementation and data sources differ greatly. For example, Google is likely providing wifi location database results fused in with GPS results (almost guaranteed when stationary on a developer's desk connected to wifi), whereas we do not because there is no open database of such things.
thanks for your response, same when device even in motion, however I solved the issue with java Timer class. whether Lost updates the location based on given interval or not I'm sending the location to the server.
Ok in motion could be an issue :) We should be getting responses back faster than that. What device are you testing on ?
Huawei Honor 8 and HTC Desire 616
how to calculate the waypoints from google direction api when i have arround 150 to 200 latitude and longitude values
Closing as this repo is no longer maintained.
Description
Hi, I'm using lost for background geolocating user every 5 second. I set the interval to 5000 and smallestDisplacement to 0 and also priority HIGH_ACCURACY but the geolocating user done randomly sometimes 2 seconds and then 15 seconds later sends another location
Steps to Reproduce
here's my code:
final com.mapzen.android.lost.api.LocationRequest locationRequest = com.mapzen.android.lost.api.LocationRequest.create() .setPriority(com.mapzen.android.lost.api.LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(10) .setFastestInterval(0) .setSmallestDisplacement(0); FusedLocationApi.requestLocationUpdates(client, locationRequest, locationListener);
Lost & Android Version
Lost : 3.0.2 Android: 5.0.1