There simply is NO guarantee that it will get an exact address. From
the method description: "The results are a best guess and are not
guaranteed to be meaningful or correct."  You may also want to pull
data from the address with getAdminArea() and getSubAdminArea().


On Sep 1, 6:04 am, ragavendran s <[email protected]> wrote:
> whenever i run this code it shows Latitude and Longitude correctly...
>
>   but i did'nt get the address,Country name and Postal code.Here I Used
> Reverse
>
>   Geocoder.  In my output Only Latitude and Longitude shows but Adddress
> Detaily   are not Displaying
>
>   can u tel me pls. thanks,
>
>  WithRegards,
>
>  S.raghav
>
>  public class WhereAmI extends Activity {
> �...@override
>  public void onCreate(Bundle icicle) {
>  super.onCreate(icicle);
>  setContentView(R.layout.main) ;
>  LocationManager locationManager;
>  String context = Context.LOCATION_SERVICE;
>  locationManager = (LocationManager)getSystemService(context);
>  String provider = LocationManager.GPS_PROVIDER;
>  Location location = locationManager.getLastKnownLocation(provider);
>  updateWithNewLocation(location);
>  }
>
>         private void updateWithNewLocation(Location location) {
>         String latLongString = null;
>         TextView myLocationText;
>         String addressstring="No address Found";
>         myLocationText = (TextView)findViewById(R.id.myLocationText);
>         if (location != null) {
>         double lat = location.getLatitude();
>         double lng = location.getLongitude();
>            latLongString = "Lat:" + lat + "\n Long: " + lng;
>
>             Geocoder gc=new Geocoder(this,Locale.getDefault());
>          try {
>             List<Address> addresses=gc.getFromLocation(lat,lng,5);
>             StringBuilder sb=new StringBuilder();
>
>             if(addresses.size()>0)
>              {
>
>                 Address address=addresses.get(0);
>
>                 for(int i=0;i<address.getMaxAddressLineIndex();i++)
>
>                 {
>                     sb.append(address.getAddressLine(i)).append("\n");
>                     sb.append(address.getCountryName()).append("\n");
>                     sb.append(address.getCountryCode()).append("\n");
>                     sb.append(address.getPostalCode());
>                 }
>
>             }
>
>                    addressstring=sb.toString();
>
>         }
>         catch (IOException e) {
>              // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>         }
>             else
>             {
>                 latLongString = "No location found";
>
>             }
>
>            myLocationText.setText("Your Current Position is:\n"
> +latLongString+"\n"+addressstring);
>
>         }
>
> }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to