proper provider parameter for requestLocationUpdates

Last Updated:

  1. shroge

    shroge New Member This Topic's Starter

    Jun 23, 2010
    Likes Received:
    I'm fairly new to android and I'm trying to create a location based app. I'm currently using the LocationManager.GPS_PROVIDER as follows:

    Code (Text):
    1. locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000, 1, locationListener);
    Does the LocationManager.GPS_PROVIDER contain the best provider available? I checked the android online documentation for LocationManager and can't seem to find anything definitive on where the value of GPS_PROVIDER comes from. I've noticed that I can manually get the best provider by the following:

    Code (Text):
    1. Criteria criteria = new Criteria();
    2. bestProvider = locationManager.getBestProvider(criteria, false);
    Which way to get the provider is considered the correct way?

    I was also wondering about how the location update mechanism deals with someone who is moving and passes from one best gps provider to another. For instance if someone is traveling on a train/car that goes a fairly long distance. Is the original requestLocationUpdates updated with the new best gps provider? If not, I suppose the best provider should be checked in onLocationChanged and then a new requestLocationUpdates given.

    Thanks for the help...

  2. dmitriyk

    dmitriyk Active Member

    Apr 17, 2010
    Likes Received:
    I use this. It works well: fast and accurate.

    Code (Text):
    1. Criteria locationCriteria = new Criteria();
    2. locationCriteria.setAccuracy(Criteria.ACCURACY_FINE);
    4. lm.requestLocationUpdates(lm.getBestProvider(locationCriteria, true), 0, 0, currentLocationListener);

Share This Page