Code example for LocationManager: Finding current location

Methods: getLastKnownLocation

0
                          loc.getAccuracy()));
    } 
  } 
 
  private Location getBestLocation() {
    Location gps=mgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    Location network=
        mgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
 
    // start off by handling cases where we only have one 
 
    if (gps == null) {
      return(network);
    } 
 
    if (network == null) {
      return(gps);
    } 
 
    Location older=(gps.getTime() < network.getTime() ? gps : network);
Stop searching for code, let great code find you!  Add Codota to your java IDE