netLoc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } // If there are both values use the latest one if (gpsLoc != null && netLoc != null){ if (gpsLoc.getTime() > netLoc.getTime()) { return gpsLoc; } else { return netLoc; } } if (gpsLoc != null) { return gpsLoc; } if (netLoc != null) { return netLoc; } return null; }