Wednesday 22 February 2012

Get Address from latitude longitude in Android

In Android to Get address from location using Geocoder
Geocoder is a class for handling geocoding and reverse geocoding.
Geocoding is the process of transforming a street address to (latitude,logitude) coordinate.
Reverse geocoding is the process of transorming (latitude,logitude) coordinate to Street address.

Here we can get address based on coordinates using Revierse geocoding
and set Address in to Textview


 Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
       try {
  List<Address> noofaddresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1);
   if(addresses != null) {
   Address retursAddress= noofaddresses.get(0);
   StringBuilder strReturnedAddress = new StringBuilder("Address is:\n");
   for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {
    strReturnedAddress.append(returnsAddress.getAddressLine(i)).append("\n");
   }
   myAddress.setText(strReturnedAddress.toString());
  }
  else{
   myAddress.setText("No Address returned!");
  }catch(Exception e){

}

Click here to Download Full Souce -> Find Address from latitude and longitude in Android



No comments:

Post a Comment

Android SQLite Database Viewer or Debuging with Stetho

Every Android Developer uses SQLite Database to store data into the Android Application data. But to view the data in SQLite have a lot of...