Ver Mensaje Individual
  #2  
Viejo 06/09/12, 09:31:53
Avatar de javito19
javito19 javito19 no está en línea
Miembro del foro
Mensajes: 364
Compra y venta: (10)
 
Fecha de registro: feb 2009
Mensajes: 364
Tu operador: Movistar
Mencionado: 1 comentarios
Tagged: 0 hilos
Prueba con esto:

Una vez que tienes tu objeto jsonObject ya puedes empezar a recorrerlo.

Un saludo

JSONObject jsonObject = new JSONObject( readJSON( tu URL ) );

public String readJSON(String url) {
StringBuilder builder = new StringBuilder();
try {
httpGet.setURI( new URI(url) );
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} else {
Log.e(ParseJSON.class.toString(), "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch ( URISyntaxException e){
e.printStackTrace();
}
return builder.toString();
}
Responder Con Cita