Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LocationRequest smallest displacement and accuracy

I'm building an Android app in which I need to have a very accurate location at a very high frequency. I dove into google play services api for location, and found the LocationRequest.setSmallestDisplacement very useful to limit battery consumption.

However, as I am testing it indoor, the locations I get have an accuracy that varies a lot (sometimes 10m, sometimes 96m...), even when I set the Priority of my request as high accuracy.

My prob1em is that setSmallestDisplacement doesn't give a sh*it about the accuracy that is returned last. So if I get a location with a very low accuracy, I will still have to walk my "smallest displacement" distance to get a new one, hopefully more accuracte.

I wonder if there is a way to avoid such data (I can't use location that are not accurate enough) or if I have to skip the setSmallestDisplacement part (bad for battery consumption).

Some code for your pleasure:

mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(100); //We get a new location every 100ms or so
//mLocationRequest.setSmallestDisplacement(5);  //but only if we traveled 5m
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

Thanks.

like image 777
Gyome Avatar asked Mar 12 '14 22:03

Gyome


People also ask

What is LocationRequest?

public final class LocationRequest extends Object. implements Parcelable. An encapsulation of various parameters for requesting location through FusedLocationProviderClient . There are a variety of different situations where various types of applications may want to use different request parameters.

What is setFastestInterval?

Save this answer. Show activity on this post. Based on the relevant Android documentation: setInterval(long) means - set the interval in which you want to get locations. setFastestInterval(long) means - if a location is available sooner you can get it (i.e. another app is using the location services).


1 Answers

The "LocationRequest.setSmallestDisplacement" doesn't matter for accuracy, it's just to avoid unnecessary updates, you can continuing using that.

There is no method to enhance low accuracy, you just get a point with some accuracy (better or worse), if you are not interested on positions with low accuracy just skip this location and wait for a better one.

This page could help you about accuracy and consumption, but take in mind no perfect accuracy exist, with Wi-Fi the accuracy is 100m for worse accuracy.

Here you have the accuracy for each priority.
https://developer.android.com/training/location/receive-location-updates.html#location-request

Here the IO Session from Google engineers, very useful, you can get the PDF there too.
https://developers.google.com/events/io/sessions/325337477

Updated Links brokens

The PDF Presentation

The IO session

Hope this helps :D.

like image 192
Sulfkain Avatar answered Sep 20 '22 11:09

Sulfkain