Viene visualizzato l'errore "L'host di destinazione non deve essere nullo o impostato nei parametri".Il nome host potrebbe non essere nullo in HttpResponse execute per android
- FACCIO hanno permesso Internet nel mio file manifesto
- Ho messo 'http: //' prima del mio URL
- FACCIO codificare l'URL
Questo è il mio codice:
String url = "http://maps.google.com/maps/api/directions/json?origin=1600 Pennsylvania Avenue NW, Washington, DC 20500&destination=1029 Vermont Ave NW, Washington, DC 20005&sensor=false";
HttpClient httpclient = new DefaultHttpClient();
String goodURL = convertURL(url);//change weird characters for %etc
HttpPost httppost = new HttpPost(goodURL);
HttpResponse response = httpclient.execute(httppost);
Nella quinta riga (ultima riga sopra), il mio programma genera un'eccezione. qui è l'errore esatto:
java.lang.IllegalArgumentException: Host name may not be null
I Do codificare la mia stringa nel metodo convertURL ...
goodURL = http://maps.google.com/maps/api/directions/json?origin=3%20Cedar%20Ave%2c%20Highland%20Park%2c%20NJ%2008904&destination=604%20Bartholomew%20Road%2c%20Piscataway%2c%20New%20Jersey%2008854&sensor=false
Qualche suggerimento? Grazie!
Non è possibile avere spazi nell'URL! fammi vedere come stai codificando il tuo URL – Samer
Il tuo problema è probabilmente nella tua funzione convertURL ... usa un debugger e controlla per vedere cosa sta tornando. – Joel
Ciao! Stavo passando l'intero URL, l'ho modificato ma continua a darmi l'errore ... goodURL = 'http://maps.google.com/maps/api/directions/json?origin=3%20Cedar%20Ave%2c % 20Highland% 20Park% 2c% 20NJ% 2008904 e destinazione = 604% 20Bartholomew% 20Road% 2c% 20Piscataway% 2c% 20New% 20Jersey% 2008854 & sensor = false' – cafesanu