Что я делаю: Я пытаюсь сделать обратное геокодирование в андроидеjava.lang.IllegalArgumentException: недопустимый символ в запросе на индексе 59
я получаю сообщение об ошибке, как :: Ява. lang.IllegalArgumentException: недопустимый символ в запросе на индексе 59: http://maps.google.com/maps/api/geocode/json?address=Agram, Бангалор, Карнатака, Индия & датчика = ложный
Примечание: этот запрос получает ответ JSON в браузере, но не из моего класса ниже
Эта линия дает эту ошибку ::
HttpGet httpget = new HttpGet(url);
JSONfunctions.java
public class JSONfunctions {
public static JSONObject getJSONfromURL(String url) {
InputStream is = null;
String result = "";
JSONObject jArray = null;
// Download JSON data from URL
try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// Convert response to string
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
try {
jArray = new JSONObject(result);
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
return jArray;
}
}
Рассмотрите URL-адрес, кодирующий значения вашего URL-адреса. – laalto
@laalto ... Не могли бы вы показать в качестве ответа, я новичок, чтобы делать запросы на кодирование! – Devrath
Возможный дубликат [кодировки URL-адресов Java] (http://stackoverflow.com/questions/10786042/java-url-encoding) – ToYonos