void startRetrievingLocation(final Context context){
  locationManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
  try {
    currentBestLocation=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    Location gpsLocation=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if (isBetterLocation(gpsLocation)) {
      currentBestLocation=gpsLocation;
    }
  }
 catch (  SecurityException e) {
    log.warning("SecurityException when retrieving the last known " + "location: " + e.getMessage());
  }
catch (  IllegalArgumentException e) {
    log.warning("IllegalArgumentException when retrieving the last known " + "location: " + e.getMessage());
  }
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,LOCATION_PROVIDER_UPDATE_RATE,LOCATION_PROVIDER_UPDATE_DISTANCE,locationListener);
  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,LOCATION_PROVIDER_UPDATE_RATE,LOCATION_PROVIDER_UPDATE_DISTANCE,locationListener);
}

void startRetrievingLocation ( final Context context ) { locationManager = ( LocationManager ) context . getSystemService ( Context . LOCATION_SERVICE ) ; try { currentBestLocation = locationManager . getLastKnownLocation ( LocationManager . NETWORK_PROVIDER ) ; Location gpsLocation = locationManager . getLastKnownLocation ( LocationManager . GPS_PROVIDER ) ; if ( isBetterLocation ( gpsLocation ) ) { currentBestLocation = gpsLocation ; } } catch ( SecurityException e ) { log . warning ( "SecurityException when retrieving the last known " + "location: " + e . getMessage ( ) ) ; } catch ( IllegalArgumentException e ) { log . warning ( "IllegalArgumentException when retrieving the last known " + "location: " + e . getMessage ( ) ) ; } locationManager . requestLocationUpdates ( LocationManager . GPS_PROVIDER , LOCATION_PROVIDER_UPDATE_RATE , LOCATION_PROVIDER_UPDATE_DISTANCE , locationListener ) ; locationManager . requestLocationUpdates ( LocationManager . NETWORK_PROVIDER , LOCATION_PROVIDER_UPDATE_RATE , LOCATION_PROVIDER_UPDATE_DISTANCE , locationListener ) ; }
starts retrieving location updates .
