Saturday, November 5, 2011

Android Tutorial Communication with Server using Http step 3

67}catch(Exception ex){
68txtResult.setText("Failed Connect to server!");
69}
70
71}
72/**
73* Method untuk Menerima data dari server
74* @param response
75* @return
76*/
77public static String request(HttpResponse response){
78String result = "";
79try{
80InputStream in = response.getEntity().getContent();
81BufferedReader reader = new BufferedReader(new InputStreamReader(in));
82StringBuilder str = new StringBuilder();
83String line = null;
84while((line = reader.readLine()) != null){
85str.append(line + "\n");
86}
87in.close();
88result = str.toString();
89}catch(Exception ex){
90result = "Error";
91}
92return result;
93}
94
95}



Step 1, Step 2, Step 3, step 4

0 komentar:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan