How do i get gps co-ordinates of the location/address entered by user in android ?
You can use Android's Geocoder
to do reverse geocoding:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List addresses = geocoder.getFromLocationName(myLocation, 1);
Address address = addresses.get(0);
double longitude = address.getLongitude();
double latitude = address.getLatitude();
Also include the following in AndroidManifest.xml
:
Also note that you need to be using an API which includes a Geocoder
implementation. APIs which include this are the Android Google APIs for example. You can use Geocoder.isPresent()
to check if an implementation exists for your targeted API.
Check out the Geocoder
documentation for more information.