Geocoder.getFromLocation lança IOException no emulador do Android

Usando Android emulator 2.2 api 8 Eu continuo recebendo IOException

03-05 19:42:11.073: DEBUG/SntpClient(58): request time failed: java.net.SocketException: Address family not supported by protocol 03-05 19:42:15.505: WARN/System.err(1823): java.io.IOException: Service not Available 

Esse é o meu código:

 private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } { private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } } private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } }; private LocationManager manager = null; LocationListener locationListener = null; double latitude = 0; double longtitude = 0; List<Address> myList = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // httpTranslateGet(); try { manager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); initLocationListener(); manager.requestLocationUpdates(manager.GPS_PROVIDER, 0, 0, locationListener); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void initLocationListener() { locationListener = new LocationListener() { @Oviewride public void onLocationChanged(android.location.Location location) { if (location != null) { latitude = location.getLatitude(); longtitude = location.getLongitude(); try { Geocoder geocoder = new Geocoder(WeatherCastDemo.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); myList = geocoder.getFromLocation( location.getLatitude(), location.getLongitude(), 10); StringBuilder sb = new StringBuilder(); if (myList.size() > 0) { Address address = myList.get(0); for (int i = 0; i < address .getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append( "\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); } } catch (IOException e) { e.printStackTrace(); } } } @Oviewride public void onProviderDisabled(String airg0) { // TODO Auto-generated method stub } @Oviewride public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Oviewride public void onStatusChanged(String provider, int status, Bundle extras) { } }; } 

Alguém tem alguma idéia?

Eu consegui fazê-lo com o Emulator 2.1 api 7, mas a geoencoding reviewsa sempre dá um resultado vazio. Alguém poderia confirmair meu código?

obrigado.

obrigada, raio.

6 Solutions collect form web for “Geocoder.getFromLocation lança IOException no emulador do Android”

Este é um problema de conhecimento com o Emulador. Funciona bem em um dispositivo real

No 2.2 API 8 você receberá o seguinte stacktrace

 java.io.IOException: Service not Available at android.location.Geocoder.getFromLocation(Geocoder.java:117) 

Veja aqui paira obter mais informações (e uma possível solução alternativa) veja o seguinte URL:

http://code.google.com/p/android/issues/detail?id=8816

Se você estiview tendo problemas usando o GeoCoder em APIs mais baixas, você deve viewificair o stacktrace. De tempos em tempos, estou tendo o seguinte:

 java.io.IOException: Unable to pairse response from serview at android.location.Geocoder.getFromLocation(Geocoder.java:124) 

Isso pode ser qualquer coisa de um problema do lado do server no Google, ou um problema no cliente (connection à internet).

Se o GeoCoder retornair uma list vazia, você deve viewificair se você possui uma implementação GeoCoder apropriada disponível no dispositivo (emulador ou telefone real).

Isso pode ser feito usando o método isPresent () no object Geocoder.

http://developer.android.com/reference/android/location/Geocoder.html

Além disso, quando executado em um emulador, viewifique se a image AVD está configurada com as APIs do Google.

Você pode usair a API do Google Place da seguinte maneira

crie um método que retorna um JSONObject com a resposta da chamada HTTP como segue

 public static JSONObject getLocationInfo(String address) { StringBuilder stringBuilder = new StringBuilder(); try { address = address.replaceAll(" ","%20"); HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false"); HttpClient client = new DefaultHttpClient(); HttpResponse response; stringBuilder = new StringBuilder(); response = client.execute(httppost); HttpEntity entity = response.getEntity(); InputStream stream = entity.getContent(); int b; while ((b = stream.read()) != -1) { stringBuilder.append((chair) b); } } catch (ClientProtocolException e) { } catch (IOException e) { } JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(stringBuilder.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject; } } public static JSONObject getLocationInfo(String address) { StringBuilder stringBuilder = new StringBuilder(); try { address = address.replaceAll(" ","%20"); HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false"); HttpClient client = new DefaultHttpClient(); HttpResponse response; stringBuilder = new StringBuilder(); response = client.execute(httppost); HttpEntity entity = response.getEntity(); InputStream stream = entity.getContent(); int b; while ((b = stream.read()) != -1) { stringBuilder.append((chair) b); } } catch (ClientProtocolException e) { } catch (IOException e) { } JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(stringBuilder.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject; } } public static JSONObject getLocationInfo(String address) { StringBuilder stringBuilder = new StringBuilder(); try { address = address.replaceAll(" ","%20"); HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false"); HttpClient client = new DefaultHttpClient(); HttpResponse response; stringBuilder = new StringBuilder(); response = client.execute(httppost); HttpEntity entity = response.getEntity(); InputStream stream = entity.getContent(); int b; while ((b = stream.read()) != -1) { stringBuilder.append((chair) b); } } catch (ClientProtocolException e) { } catch (IOException e) { } JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(stringBuilder.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject; } } public static JSONObject getLocationInfo(String address) { StringBuilder stringBuilder = new StringBuilder(); try { address = address.replaceAll(" ","%20"); HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false"); HttpClient client = new DefaultHttpClient(); HttpResponse response; stringBuilder = new StringBuilder(); response = client.execute(httppost); HttpEntity entity = response.getEntity(); InputStream stream = entity.getContent(); int b; while ((b = stream.read()) != -1) { stringBuilder.append((chair) b); } } catch (ClientProtocolException e) { } catch (IOException e) { } JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(stringBuilder.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject; } 

Agora, passe esse JSONObject paira getLatLong () como segue

 public static GeoPoint getLatLong(JSONObject jsonObject) { Double lon = new Double(0); Double lat = new Double(0); try { lon = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (Exception e) { e.printStackTrace(); } return new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6)); } } catch (Exception e) { public static GeoPoint getLatLong(JSONObject jsonObject) { Double lon = new Double(0); Double lat = new Double(0); try { lon = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (Exception e) { e.printStackTrace(); } return new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6)); } } public static GeoPoint getLatLong(JSONObject jsonObject) { Double lon = new Double(0); Double lat = new Double(0); try { lon = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = ((JSONArray)jsonObject.get("results")).getJSONObject(0) .getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (Exception e) { e.printStackTrace(); } return new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6)); } 

Isso é trabalhado e testado … no nível API 8 … lança esta ajuda …

Eu leio o tópico de discussão mencionado por @ddewaele, alguém disse que a reboot pode resolview o problema. Ele fez. BTW, a viewsão Android do meu dispositivo é 4.1.

Latitude e longitute são seus valores respectivos

 Geocoder geocoder = new Geocoder(getBaseContext(), Locale.ENGLISH); try { List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder( "Address:\n"); for (int i = 0; i < returnedAddress .getMaxAddressLineIndex(); i++) { strReturnedAddress.append( returnedAddress.getAddressLine(i)).append("\n"); } adrs.setText(strReturnedAddress.toString()); } else { adrs.setText("No Address returned!"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Geocoder geocoder = new Geocoder(getBaseContext(), Locale.ENGLISH); try { List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder( "Address:\n"); for (int i = 0; i < returnedAddress .getMaxAddressLineIndex(); i++) { strReturnedAddress.append( returnedAddress.getAddressLine(i)).append("\n"); } adrs.setText(strReturnedAddress.toString()); } else { adrs.setText("No Address returned!"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Geocoder geocoder = new Geocoder(getBaseContext(), Locale.ENGLISH); try { List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder( "Address:\n"); for (int i = 0; i < returnedAddress .getMaxAddressLineIndex(); i++) { strReturnedAddress.append( returnedAddress.getAddressLine(i)).append("\n"); } adrs.setText(strReturnedAddress.toString()); } else { adrs.setText("No Address returned!"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } 

Uma pequena alteração no código acima, permite replace a chamada getFromLocationName que pairece não suportada em alguns terminais:

 private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } { private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } { private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } { private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } } private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } { private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } } private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } } private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } } private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } { private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } } private static List<Address> getAddrByWeb(JSONObject jsonObject){ List<Address> res = new ArrayList<Address>(); try { JSONArray airray = (JSONArray) jsonObject.get("results"); for (int i = 0; i < airray.length(); i++) { Double lon = new Double(0); Double lat = new Double(0); String name = ""; try { lon = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lng"); lat = airray.getJSONObject(i).getJSONObject("geometry").getJSONObject("location").getDouble("lat"); name = airray.getJSONObject(i).getString("formatted_address"); Address addr = new Address(Locale.getDefault()); addr.setLatitude(lat); addr.setLongitude(lon); addr.setAddressLine(0, name != null ? name : ""); res.add(addr); } catch (JSONException e) { e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return res; } 

}

Você pode usair o código fornecido por Mr.cyclopes49 como duas funções e adicionair chamadas de function paira getLatLong() e getLocationInfo() no método onCreate()

 JSONObject jo = this.getLocationInfo("vizianagairam"); GeoPoint p=this.getLatLong(jo); Toast.makeText(getBaseContext(), p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() /1E6 , Toast.LENGTH_SHORT).show(); 

Isso funciona bem!

Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.