1

In my application, I have a requirement where I need to track the user's current place and notify the user if he/she stays for some time. So to do this, I am using Google's place SDK to get current place detail, reference link But the problem is output.

If I use Location service with priority PRIORITY_HIGH_ACCURACY or PRIORITY_BALANCED_POWER_ACCURACY, the output of Place SDK is different for the same location.

My Location Request is as below:

LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); 
// or
// mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);

As mentioned in above link, we don't have any option to pass current latitude-longitude, as SDK itself manage it.

So can anyone help me how I can get much accurate output from Place SDK.

Sample code of background service

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mehta
  • 1,228
  • 1
  • 9
  • 27
  • 1
    can't you retrieve the position as LatLng and check that the user stays in a given radius instead of using Places API ? – andrei Sep 19 '18 at 11:07
  • In my project, where I need to use place details such as Place ID, name, address etc.. – Mehta Sep 19 '18 at 11:12
  • Exactly, where you need to use place details you'll use place details. But here it is not the best solution and you should just check how the position changes over time – andrei Sep 19 '18 at 12:12

1 Answers1

0

as the documentation states, you probably should migrate to GoogleApi Client

while the two different results returned, should have a different PlaceLikelihood.

as a matter of fact, the less precise the requested location is, the less accure the returned places are.

for the LocationRequest, there isn't even a PRIORITY_BALANCED, but only a PRIORITY_BALANCED_POWER_ACCURACY constant available - and the request interval will be automatically throttled when this is set, no matter what you try to set as the interval.

also see the FusedLocationProviderClient.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I have used FusedLocationProviderClient for location update. – Mehta Sep 19 '18 at 11:14
  • @Mehta try logging the returned location, because the Places API (or GoogleApi Client) will show different results, because two different locations are being requested. "block level" accuracy is not really a GPS fix. it might depend where one requests it - sometimes the results might even be quite similar. the output will always depend on the input. – Martin Zeitler Sep 19 '18 at 11:18
  • true. but in Place SDK, we don't have any provision to pass current Latitude- Longitude. PlaceDetectionClient itself fire a request to get the current location to the device and after getting current location, it will give a list of places – Mehta Sep 19 '18 at 11:35
  • @Mehta the API would feature "Nearby Search", which permits lookup by coordinates - with the Places SDK, you don't have the option to do so (even if this might appear questionable). see this answer for an example: https://stackoverflow.com/a/31035938/549372 – Martin Zeitler Sep 19 '18 at 11:45
  • Let me try this nearby search API – Mehta Sep 19 '18 at 12:16