-
Notifications
You must be signed in to change notification settings - Fork 123
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
Almost duplicate requests to onLocationFound #17
Comments
Hi ! Thanks for the feedback, even if its .. weird ! It just forwards the locations obtained by the system ! I'll have a look soon |
Got the same issue as well. Though i set 30 second frequency between updates but i am getting location updates on irregular intervals like after 5 seconds, 2 seconds etc
Check this image. I have logged the locations to a .gpx file and then exported the data to visualize my trek. You need to see the time between locations. |
FOA, if the distance is not specified, the /**
* The default distance between location updates
* Its value is 100m
*/
public static final float DEFAULT_MIN_METERS_BETWEEN_UPDATES = 100;
I'm having a look at the [Android doc of the I've found something interesting a [bit latter in the doc](https://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28java.lang.String, long, float, android.location.LocationListener%29)
Were you having another application using any "Location Updates" running ? Maybe I could add a kind of test to be sure that the elapsed time is corresponding to what the settings contains ? |
Hi - I did specify ".setMetersBetweenUpdates(20)" so that should override the default 100m you found, but be overridden itself (?) by the ".setTimeBetweenUpdates(1000 * 30)" call. My findings were from a live, external test with my working phone, so it's entirely possible that other apps were polling locations passively or through network, but I don't think via GPS. It's not a major bug and I can easily ignore the duplicates, but just feel that you should be aware it's happening and maybe put a note into GITHUB for other users - unless you do add a test clause somewhere. Thanks for looking into this, much appreciated! |
Hi, Thanks for your efforts. I think i found some thing that you will like to see. /**
* Called when the tracker had found a location
*
* @see android.location.LocationListener#onLocationChanged(android.location.Location)
*/
@Override
public final void onLocationChanged(@NonNull Location location) {
Log.i(TAG, "Location has changed, new location is " + location);
LocationTracker.sLocation = new Location(location);
mIsLocationFound = true;
onLocationFound(location);
} Instead of this i am using this, and now my issue is resolved. @Override
public final void onLocationChanged(@NonNull Location location) {
Log.i(TAG, "Location has changed, new location is " + location);
if( LocationTracker.sLocation == null){
LocationTracker.sLocation = new Location(location);
}
mIsLocationFound = true;
onLocationFound(location);
} Then i set the min_time_between_updates to 10 sec. And got perfect results. Your Thoughts ? |
That is very... weird ! And the thing is, if you only set it when null, it won't be updated for the next time you ask for it :/ More, maybe setting the sLocation is no this useful as I can still use the So the method would be: @Override
public final void onLocationChanged(@NonNull Location location) {
Log.i(TAG, "Location has changed, new location is " + location);
mIsLocationFound = true;
onLocationFound(location);
} |
Also in my case, onLocationFound (method is in service) is called two times with exactly same GPS location. In this example, between calls is 00:00:00.028 time difference, usually within ~ 50 milliseconds. Example: 11-07 10:20:34.922: Location has changed, new location is Location[...] My tracker settings: |
Hafner91 same here.i get location twice |
Hi - great library, thanks for developing and sharing.
I have an issue in that I seem to be getting duplicate calls to onLocationFound(Location loc). They are not exact duplicates in that they are usually within ~100 milliseconds of each other. Below is output from using 30 second time interval using your example code:
settings = new TrackerSettings()
.setUseGPS(true)
.setUsePassive(true)
.setUseNetwork(true)
.setTimeBetweenUpdates(1000 * 30)
.setMetersBetweenUpdates(20);
The output is Latitude, Longitude, Accuracy, Time (millisecs), Cumulative distance. This was collected when I was walking tracking a route.
52.3980456,-1.526949, 18.955, 1477316971912, 6
52.3980456,-1.526949, 18.955, 1477316971974, 6
52.39800801,-1.52702431, 9.0, 1477316973661, 13
52.39777663,-1.52684439, 5.0, 1477316992652, 42
52.39777663,-1.52684439, 5.0, 1477316992681, 42
52.3975514,-1.52639864, 4.0, 1477317013671, 81
52.39745864,-1.5262795, 8.0, 1477317023666, 94
52.3977192,-1.5264435, 23.388, 1477317033140, 125
52.39740684,-1.52612629, 5.0, 1477317033711, 166
52.39738598,-1.52595222, 9.0, 1477317042658, 178
52.3973101,-1.52579648, 7.0, 1477317052669, 192
52.3975554,-1.5262395, 19.427, 1477317053187, 232
52.3975554,-1.5262395, 19.427, 1477317053210, 232
52.39716856,-1.5253993, 8.0, 1477317073681, 304
52.39716856,-1.5253993, 8.0, 1477317073714, 304
52.396897,-1.52528835, 6.0, 1477317093664, 335
52.396897,-1.52528835, 6.0, 1477317093677, 335
52.39666517,-1.52568172, 6.0, 1477317113081, 372
52.39666517,-1.52568172, 6.0, 1477317113094, 372
52.39656626,-1.5259295, 5.0, 1477317123083, 392
52.39656626,-1.5259295, 5.0, 1477317123093, 392
52.39666626,-1.52624856, 8.0, 1477317144116, 417
52.39671506,-1.52649306, 5.0, 1477317153693, 434
52.39678975,-1.52667512, 6.0, 1477317164102, 449
52.3968655,-1.52684107, 4.0, 1477317173730, 463
52.39697536,-1.52708833, 8.0, 1477317183689, 484
52.39697536,-1.52708833, 8.0, 1477317183705, 484
52.39714838,-1.52749132, 8.0, 1477317204116, 518
52.397255,-1.52766193, 6.0, 1477317213695, 534
52.39750574,-1.52741519, 9.0, 1477317223083, 567
52.39751272,-1.52729175, 8.0, 1477317233115, 575
52.39755086,-1.527116, 6.0, 1477317244102, 588
52.39767366,-1.52696935, 9.0, 1477317254678, 605
52.39778008,-1.52685321, 6.0, 1477317264115, 619
52.39791,-1.52683434, 8.0, 1477317273103, 634
52.39803259,-1.52688624, 6.0, 1477317284112, 648
52.39813587,-1.52689322, 9.0, 1477317293677, 659
I can easily ignore these almost duplicate values (in bold), but wondered if you can explain why they might be happening?
Many thanks - and again, useful and easy to use library!
The text was updated successfully, but these errors were encountered: