public static boolean isValidLocation(Location location){
  return location != null && Math.abs(location.getLatitude()) <= 90 && Math.abs(location.getLongitude()) <= 180;
}

public static boolean isValidLocation ( Location location ) { return location != null && Math . abs ( location . getLatitude ( ) ) <= 90 && Math . abs ( location . getLongitude ( ) ) <= 180 ; }
checks if a given location is a valid ( i . e . physically possible ) location on earth . note : the special separator locations ( which have latitude = 100 ) will not qualify as valid . neither will locations with lat = 0 and lng = 0 as these are most likely " bad " measurements which often cause trouble .
