M0286_Libro Curso
4: Web móvil en acción
} catch (ClientProtocolException e) {
client.getConnectionManager().shutdown(); e.printStackTrace(); client.getConnectionManager().shutdown(); e.printStackTrace();
} catch (IOException e) {
}
} Y por último, debemos declarar el método convertStreamToString() que parsea el InputStream devuelto en cadena de texto: private static String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + “\n”); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } } También debemos crear la clase RequestMethod.java donde definiremos los tipos enum de RequestMethod . package com.seas.ejemplo.RestService; public enum RequestMethod {
GET , POST
} Si ejecutamos la aplicación, nos muestra la Activity principal Start :
239
Made with FlippingBook - Online catalogs