Ho un problema che voglio analizzare un file XML sul web. Ora anche il mio HttpResponce ha troppo tempo per leggere quel file XML, quindi ottengo l'errore "Become Runtime Error" per le mie GUI.HttpResponse in Android
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://chukk.nuzoka.com/name.xml");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (MalformedURLException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (IOException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
}
Ogni aiuto è apprezzato :)
fare questo in un thread separato giusto? – L7ColWinters
Solo una nota a margine, considera l'utilizzo di StreamReader invece di EntityUtils.toString, per un miglioramento dell'utilizzo della memoria. – yorkw
@yorkw Hai qualcosa da sostenere? Sto usando EntityUtils .. – nhaarman