Code example for Location

Methods: getAccuracygetLatitudegetLongitudegetProvidergetTime

0
      Log.wtf(getClass().getSimpleName(),
              "Got null for getBestLocation()"); 
    } 
    else { 
      Log.i(getClass().getSimpleName(),
            String.format("%s %f:%f (%f meters)", loc.getProvider(),
                          loc.getLatitude(), loc.getLongitude(),
                          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);
    Location newer=(gps == older ? network : gps);
 
    // older and less accurate fixes suck 
 
    if (older.getAccuracy() <= newer.getAccuracy()) {
      return(newer);
    } 
 
    // if older is within error radius of newer, assume 
    // not moving and go with older (since has better