0

I am using FusedLocationProviderClient to get location update in my app. I am creating LocationRequest with interval of 1 sec and maxInterval of 0.5 sec but location update is taking average of 6 sec.

I am testing this on Nexus 5, Nexus 5x and Moto G (2nd Gen) devices.

I didn't found any limit about interval or maxInterval in Documentation, So i am assuming it should give update in 1 sec atleast.

Also, I am requesting location from a Foreground Services.

Please Suggest how to get update location update each second or is there any limitation mentioned in Documentation.

Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
Randheer
  • 984
  • 6
  • 24
  • If you are not doing it in the background you can use the location callback: https://developer.android.com/training/location/receive-location-updates.html – HedeH Mar 06 '18 at 08:47
  • I am seeing the same thing. @Randheer Did you find a solution to this? – K0ICHI May 24 '22 at 14:44

1 Answers1

3

By looking at the reference by Android at: https://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html

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).

For example, you start your application and register it via setInterval(60*1000), that means that you'll get updates every 60 seconds. Now you call setFastestInterval(10*1000). If you are the only app which use the location services you will continue to receive updates every 60 seconds. If another app is using the location services with a higher rate of updates, you will get more location updates.

Note: Basically In your mobile,having some application for requesting location updates in background..that time you cannot get location updates as you set Interval..

Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
  • SetMaxInterval means :When it will trigger some another application requeste for the location so that time only MaxInterval trigger. – Gowthaman M Mar 06 '18 at 08:38
  • Thanks, I am creating Request with serInterval(1000) and setFastestInterval(500) and Priority PRIORITY_HIGH_ACCURACY but still update is taking an average of 5sec. Also I am requesting location from Foreground Services, so It should provide update more quickly. – Randheer Mar 06 '18 at 08:46
  • When you setInterval to 10sec and setFastestInterval to 5sec.Then the location update is called every 5sec. – Gowthaman M Mar 06 '18 at 09:23
  • Sure I will upvote for helpful answer, I am creating location request with 1 sec and fastInveral with 0.5 sec, but getting update in 5 sec – Randheer Mar 06 '18 at 09:28
  • @d4h i already told bro..That means may be in you mobile some other applications like facebook (or)whatsapp(or)amazon etc. requesting for the locationServices...so you cannot get exact interval – Gowthaman M Mar 06 '18 at 09:35