1. Download our Official Android App: Forums for Android!

Apps proper provider parameter for requestLocationUpdates

Discussion in 'Android Development' started by shroge, Jun 23, 2010.

  1. shroge

    shroge Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jun 23, 2010

    Jun 23, 2010
    3
    0
    5
    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...
     

    Advertisement

  2. dmitriyk

    dmitriyk Member
    Rank:
    None
    Points:
    18
    Posts:
    44
    Joined:
    Apr 17, 2010

    Apr 17, 2010
    44
    10
    18
    Software Developer
    Salt Lake City, UT
    I use this. It works well: fast and accurate.

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

Share This Page

Loading...