Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster GPS fix in Android

Tags:

android

gps

I have noticed that applications like GPS Status get a fix pretty quickly. When I try to get a fix within my own application it takes more time. Does anybody know why is this happening? Do they use a hidden part of the API to force the GPS to connect faster?

Here's what I use

LocationManager loc = (LocationManager) context
            .getSystemService(Context.LOCATION_SERVICE);
loc.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
            listener);

I want the GPS to give results as frequent as possible because I need it for an AR app :) Although I putting settings like 1000 ms and 1 m for the update frequency with no perceivable difference in speed of fix.

like image 201
Martin Marinov Avatar asked Jul 13 '10 06:07

Martin Marinov


2 Answers

Could be one of several approaches:

  • Using LocationManager.getLastKnownLocation (which, given how many apps use location data, should generally be 'close enough' if not dead accurate.)
  • Using LocationManager.NETWORK_PROVIDER instead of LocationManager.GPS_PROVIDER to get an immediate rough fix, then refining with GPS (if available).
  • Running a service in the background that periodically gets the latest position and caches it (basically the same as LocationManager.getLastKnownLocation, but doing it yourself)
like image 108
Dave Avatar answered Nov 09 '22 22:11

Dave


Here's my strategy : check this StackOverflow answer.

like image 44
Fedor Avatar answered Nov 09 '22 20:11

Fedor