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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to