ifaz / little-fluffy-location-library

Automatically exported from code.google.com/p/little-fluffy-location-library
0 stars 0 forks source link

30s delay when forcing location update #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps:
Call LocationLibrary.forceLocationUpdate() and wait 30s before getting a 
location fix. 

My app relies on getting a location fix immediately (or at least quickly) on 
startup. I call  LocationLibrary.forceLocationUpdate() in my main activity and 
was expecting to get a location fix quickly. However, it always takes 30sec 
before LocationBroadcastService starts and before I receive a callback on my 
broadcast receiver. It looks like the problem is in 
PassiveLocationChangedReceiver when it processes a single shot update. The 
delay is hardcoded to 30 seconds:

LocationBroadcastService.forceDelayedServiceCall(context, 30);

Is there a way to make it configurable? Or is there any other way to get a 
location fix faster than 30 seconds?

Original issue reported on code.google.com by mjszyman...@gmail.com on 22 Aug 2012 at 8:07

GoogleCodeExporter commented 9 years ago
The force update gives a poor location fix quickly, then a better one, or 
several better, soon after. That's why it waits for 30 seconds - it waits until 
the updates settle down and then broadcasts the best one it got.

But you're kinda missing the point of this library, which is to give you a 
reasonable location hit immediately on startup: "You can also just create a 
LocationInfo object at any time, and it will have the latest location info 
within it". The library listens all the time, and stores the latest location no 
matter what app requested it. After reboot it will still have data in it. The 
only time it won't is the first time it's ever run - you need to check for 
null. Your app should just create the LocationInfo object on startup and use 
this. You could at that point force a refresh and a better hit will arrive in 
30 seconds, but for startup, you have a pretty good location already. If you 
need different behaviour to this, take the open source and go for it :-)

Original comment by ken...@kentonprice.com on 22 Aug 2012 at 10:37