Requesting concurrent GPS and geolocation updates

You can request both GPS and geolocation updates concurrently. Requesting concurrent updates provides you with flexibility in your application to specify request parameters (for example, the frequency and timeout), and to select the most suitable location information to use based on customized criteria. For example, you might want to provide BlackBerry device users with a quick, approximate location (by using geolocation) before a more accurate GPS fix is available.

To request both GPS and geolocation updates, you must create two separate threads to request separate instances of a BlackBerryLocationProvider. One thread specifies a GPS location mode, and the other thread specifies a geolocation mode.

Code sample: Requesting concurrent GPS and geolocation updates

//In a GPS thread
try
{
    BlackBerryLocationProvider provider = (BlackBerryLocationProvider)
            LocationProvider.getInstance(new BlackBerryCriteria(
            GPSInfo.GPS_MODE_ASSIST));
} 
catch (LocationException e)
{
     showException(e);
}

//In a geolocation thread
try
{
    BlackBerryLocationProvider provider = (BlackBerryLocationProvider)
            LocationProvider.getInstance(new BlackBerryCriteria(
            LocationInfo.GEOLOCATION_MODE_CELL));
}
catch (LocationException e)
{
    showException(e);
}

Was this information helpful? Send us your comments.