i am using the following code to get the latitude and longitude values of a particular area.

public class MainActivity extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        List<Address> foundGeocode = null;
        /* find the addresses  by using getFromLocationName() method with the given address*/
        try {
            foundGeocode = new Geocoder(this).getFromLocationName("Hyderabad", 1);
            foundGeocode.get(0).getLatitude(); //getting latitude
             foundGeocode.get(0).getLongitude();//getting longitude
             Toast.makeText(this, ""+ foundGeocode.get(0).getLatitude()+"   "+foundGeocode.get(0).getLongitude(), 20).show();

        } catch (IOException e) {
            // TODO Auto-generated catch block


But the catch block is being executed instead of getting the latitude and longitude values.
Can any one help me out.

I sent values to emulator using the ddms view and later tried to work out this code.
i am getting the following warning.

07-13 09:05:13.390: W/System.err(368): java.io.IOException: Service not Available

thanks in advance.

Did you set permissions in AndroidManifest?

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

yes i used them and also included fine location.

If you are using smulator prior 4.0 you will get this. Quite lot of similar based question on stackoverflow. Are you using real device or some emulator?

Well then you have to use anything above 4.0. Be aware emulators at this stage are very slow if you do not set them right