Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

requestLocationUpdate takes too long

I have only one device (HTC HD Deside) for testing my apps and when I want to get GPS data with

locationManager.requestLocationUpdate(criteria,0,0,this); //critera = "gps"

My GPS icon appears in the notification bar but it "flashes", as if It meant my device is looking for and get the GPS data. Accordingly, my apps takes too much "thinking" times before it succeeds to get data from GPS (~1mn to 3mn !) (before the icon stop flashes)

So, I'm obliged to create a while instruction like this :

do{
    lastLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}while(System.currentTimeMillis() - lastLocation.getTime() > 5000);

Thanks that, I'm sure to get a recently location but I lost too much time.

What's the problem? is it the hardware? Can I find a better way for fix this? Can I get "quickly" the GPS data? :/ (1~5 sec)

like image 699
spacecodeur Avatar asked Oct 04 '22 18:10

spacecodeur


1 Answers

I think you should read this http://developer.android.com/guide/topics/location/strategies.html guide prior developing an location aware app.

The GPS sensor needs 1 to 3 minutes to get a fix, you can't have a very quick fix(1-5 seconds as you want).

You should use the last known location value and start requesting location fixes. When you have one, you refresh your content accordingly.

like image 128
Emil Pana Avatar answered Oct 10 '22 02:10

Emil Pana