Lavorare su un progetto che ottiene l'indirizzo da un database.
Da quegli indirizzi ottengo il LatLng e li pin su una Google mappe Activity.
Io uso questo metodo per ottenere LatLng dall'indirizzo:
public LatLng getLocationFromAddress(Context context, String inputtedAddress) {
Geocoder coder = new Geocoder(context);
List<Address> address;
LatLng resLatLng = null;
try {
// May throw an IOException
address = coder.getFromLocationName(inputtedAddress, 5);
if (address == null) {
return null;
}
if (address.size() == 0) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
resLatLng = new LatLng(location.getLatitude(), location.getLongitude());
} catch (IOException ex) {
ex.printStackTrace();
}
return resLatLng;
Fino a 2 giorni fa, mi ha dato 164 coordenates corretti da 285 indirizzi. Alcuni degli indirizzi ha dato nulla LatLng per qualche motivo.
Senza modificare il codice, ora ottengo il seguente errore per i primi 8-10 chiamate al geocoder:
W/System.err: java.io.IOException: Timed out waiting for response from server
W/System.err: at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
Dopo di che, il resto dà questo errore:
W/System.err: java.io.IOException: RPC failed with status 102
at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
La linea esatto che dà l'errore è:
address = coder.getFromLocationName(inputtedAddress, 5);
MODIFICARE:
Dopo un po 'di indagini ho scoperto che la classe Geocoder.java ha errori, mancano alcuni metodi:
Sarebbe reinstallare Android Studio lavoro?














