Android address verification

In my application, I have to accept the user address (USA). The user must enter a valid address. How can i achieve this? Is there a library that can help me with the names of states, cities, and street names? I would like to use autotype if possible. I read GeoCoding, but I don’t think this will help me, as the user is not entering an address from the current location.

+6
source share
3 answers

This is what I do to find a location using the Google APIs. Perhaps this will help you:

Geocoder geoCoder = new Geocoder(context, Locale.getDefault()); try { List<Address> addresses = geoCoder.getFromLocationName(travel.getAddress() + "," + travel.getCity() + "," + travel.getState() + "," + travel.getCountry(), 3); if (addresses.size() > 0) { point = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6), (int) (addresses.get(0).getLongitude() * 1E6)); travel.setLatitude(String.valueOf(point.getLatitudeE6())); travel.setLatitude(String.valueOf(point.getLongitudeE6())); long res = travel.update(context, null); if (res < 1){ result = false; } } } catch (IOException e) { e.printStackTrace(); result = false; } 
+2
source

Why not check the area code? You must save by doing this.

0
source

There are various ways to clear address input and standardize it in the expected format. But the only real way to verify the address to ensure that it is real and correct is to use the address verification service.

Standardizing an address is all about how everything looks good — for example, formatting and standardizing a phone number or email address. But data that looks good is not enough. You need data that is good. For example, do you accept an order if the user provides a credit card that may be good? Or do you want a good credit card? Same thing with addresses. If you collect the address, then it would be nice to know that it is real, supplied and can be used for its intended purpose. Otherwise, it’s just garbage data - garbage, garbage.

Fortunately, in your case, since the user is on an Android device, they will most likely have an Internet connection, which will allow you to fulfill a request to a third-party address verification service. There are a number of services that provide address verification. I am the founder of one of them called SmartyStreets . Our LiveAddress API may be exactly what you are looking for. And, depending on your size and business, it may well be absolutely free. If not, it doesn’t matter, there are other services that you can use.

0
source

Source: https://habr.com/ru/post/904956/


All Articles