Der Hostname darf in HttpResponse execute für Android nicht null sein

Ich erhalte die Fehlermeldung "Zielhost darf nicht null sein oder in Parametern festgelegt sein".

ICH MACHE Ich habe eine Internet-Erlaubnis in meiner Manifest-DateiIch habe 'http: //' vor meine URL gestelltICH MACHE kodiere die URL

Das ist mein Code:

   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);

In der 5. Zeile (letzte Zeile oben) löst mein Programm eine Ausnahme aus. Hier ist der genaue Fehler:

java.lang.IllegalArgumentException: Host name may not be null

Ich verschlüssele meinen String in der Methode 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

Irgendwelche Vorschläge? Vielen Dank!

Antworten auf die Frage(3)

Ihre Antwort auf die Frage