I'm building an app where I need to apply bounds on user's location (Lat,Lng) to be within city perimeters like Uber. How can I achieve this?
This one is when within city perimeters
This one is not in city or Uber's service zone.
I have tried this approach. I'm using geocoder and fetching the address of the location and matching city parameters.
addresses = geocoder.getFromLocation(lat, lon, 1);
if (addresses != null && !addresses.isEmpty()) {
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
String knownName = addresses.get(0).getFeatureName();
}
Can I use Geofencing? If yes then how?