Usando emulador de Android 2.2 API 8 me siguen dando IOExceptionGeocoder.getFromLocation throws IOException el emulador de Android
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
Ésta es mi 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()
{
@Override
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();
}
}
}
@Override
public void onProviderDisabled(String arg0)
{
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider)
{
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status,
Bundle extras)
{
}
};
}
alguien tiene alguna idea?
He logrado hacerlo con Emulator 2.1 api 7, pero la geocodificación inversa siempre da un resultado vacío. ¿alguien podría confirmar mi código?
gracias.
gracias, ray.
¿Está bajo un firewall o proxy? –
¿Estás conectado a internet con tu emulador? verifica esto usando el navegador. –
no estoy bajo firewall/proxy y sí, me conecto a internet. – rayman