Advertisement
Guest User

Code for Activity Url

a guest
Oct 9th, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. public static String makeWebCall(String url) {
  2.    
  3.         System.out
  4.         .println("@#$@#@$#$@#$@$##$-----FOR ACTIVITES ------->>>>>>>>>>>>> ---------->");
  5.         HttpGet httpRequest = new HttpGet(url);
  6.      
  7.         try {
  8.  
  9.             HttpResponse httpResponse = client.execute(httpRequest);
  10.            
  11.             System.out.println("=========> Response from login123 => "+httpResponse);
  12.            
  13.              final int statusCode = httpResponse.getStatusLine().getStatusCode();
  14.              System.out.println("=========> statusCode from the url => " + statusCode);
  15.              if (statusCode != HttpStatus.SC_OK) {
  16.              
  17.                 return null;
  18.              }
  19.              
  20.              HttpEntity entity = httpResponse.getEntity();
  21.               InputStream instream = entity.getContent();
  22.              
  23.              String streamValue =  iStream_to_String(instream);
  24.  
  25.              if (entity != null) {
  26.                  
  27.                 // httpRequest.abort();
  28.                  instream.close();
  29.                  EntityUtils.consume(entity);  
  30.                  
  31.              }
  32.              
  33.                 return streamValue;
  34.         }
  35.         catch (IOException e) {
  36.             httpRequest.abort();
  37.           // Log.w(getClass().getSimpleName(), "Error for URL =>" + url, e);
  38.         }
  39.  
  40.         return null;
  41.  
  42.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement