1

In the docs for FusedLocationProviderClient.getCurrentLocation() it says as follows:

This method may return locations that are a few seconds old, but never returns much older locations. This is suitable for foreground applications that need a single fresh current location.

Background apps calling this method will be throttled under background location limits, so background apps may find the method returns null locations more often.

What are the implications of "will be throttled"?

In my situation, I have a widget which updates at most every 30 mins. With appropriate location permissions granted (foreground and background), I can already access the last known location using FusedLocationProviderClient.getLastLocation() and this has been working fine.

But I'd like to explore a more active approach, using getCurrentLocation() instead of getLastLocation(). For a widget, with no app in the foreground, even passing LocationRequest.PRIORITY_HIGH_ACCURACY to getCurrentLocation(), I never see the little "location" icon (map pin icon) appearing in the status bar, like I'd expect to if the device were actively requesting a new location fix. Yes, ACCESS_FINE_LOCATION permission is requested and granted. Using this same method call in the app (in the foreground) and I do see the "location" icon.

So, for a widget is there any real benefit in using getCurrentLocation() instead of getLastLocation() in the background if it is going to be hampered significantly in some way? Sometimes it seems to take around 30 seconds to complete (with no visible sign in the status bar of any location access) and then return with a null location anyway, so what is it actually doing?

I could start a foreground service (with notification) but it seems overkill if the user is anyway going to have visibility (via the "location" icon in the status bar) that location is being actively accessed.

So what exactly is "throttling"? Just putting a limit on frequency (widget updates at most every 30 mins so it's hardly "frequent")? Or putting a limit on accuracy (e.g. no GPS)?

drmrbrewer
  • 11,491
  • 21
  • 85
  • 181

1 Answers1

0

I think that it probably relates to these background location limits:

In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently an app can retrieve the user's current location while the app is running in the background. Under these conditions, apps can receive location updates only a few times each hour.

drmrbrewer
  • 11,491
  • 21
  • 85
  • 181