AndroidHttpClient close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AndroidHttpClient close method.

This code example shows how to use the following methods:close, execute, getParams
      ByteArrayEntity entity = new ByteArrayEntity(mms);
 
      entity.setContentType("application/vnd.wap.mms-message");
 
      request.setEntity(entity);
      request.setParams(client.getParams());
      request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
//      request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml"); 
      request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
      HttpResponse response = client.execute(target, request);
      StatusLine status     = response.getStatusLine();
 
      if (status.getStatusCode() != 200)
        throw new IOException("Non-successful HTTP response: " + status.getReasonPhrase());
 
      return parseResponse(response.getEntity());
    } catch (URISyntaxException use) {
      Log.w("MmsSendHelper", use);
      throw new IOException("Couldn't parse URI.");
    } finally { 

8
CodeRank
This code example shows how to use the following methods:close
	        is.close();
	     } catch (Exception e) {
	    	e.printStackTrace();
	     } finally { 
	    	 if (httpclient != null) {
	    	   httpclient.close();
	    	 } 
	     } 
	     return bm;
	} 
     
    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        } 
 
        @Override 
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
6
CodeRank
This code example shows how to use the following methods:close
     * @param instance HttpClient 
     */ 
    public static void closeInstance(HttpClient instance) {
        if (instance instanceof AndroidHttpClient) {
            AndroidHttpClient client = (AndroidHttpClient) instance;
            client.close();
        } else { 
            ClientConnectionManager mgr = instance.getConnectionManager();
            if (mgr != null)
                mgr.shutdown();
        } 
    } 
 
    public static void setUserAgentString(String userAgent) {
    	sUserAgent = userAgent;
    } 
     
    public static String getUserAgentString() {
        return sUserAgent;
    } 
5
CodeRank
This code example shows how to use the following methods:close
    public boolean supportsSuggestions() { 
        return mSearchEngineInfo.supportsSuggestions();
    } 
 
    public void close() { 
        mHttpClient.close();
    } 
 
    private boolean isNetworkConnected(Context context) {
        NetworkInfo networkInfo = getActiveNetworkInfo(context);
        return networkInfo != null && networkInfo.isConnected();
    } 
 
    private NetworkInfo getActiveNetworkInfo(Context context) {
        ConnectivityManager connectivity =
                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivity == null) {
            return null; 
        } 
        return connectivity.getActiveNetworkInfo();
5
CodeRank
This code example shows how to use the following methods:close
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            if (httpclient != null) {
                httpclient.close();
            } 
        } 
        return bm;
    } 
 
    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        } 
 
        @Override 
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
4
CodeRank
This code example shows how to use the following methods:close
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            if (httpclient != null) {
                httpclient.close();
            } 
        } 
        return bm;
    } 
 
    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        } 
 
        @Override 
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
4
CodeRank
This code example shows how to use the following methods:close
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            if (httpclient != null) {
                httpclient.close();
            } 
        } 
        return bm;
    } 
 
    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        } 
 
        @Override 
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
4
CodeRank
This code example shows how to use the following methods:close
		return _hrh;
	} 
	 
	public void finalize() { 
		// don't leak; 
		client.close();
	} 
	 
	 
	public static boolean isNetworkAvailable(Context ctx) {
		// Requires NETWORK_STATE permissions 
	    ConnectivityManager cm = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
	    NetworkInfo networkInfo = cm.getActiveNetworkInfo();
	    // if no network is available networkInfo will be null 
	    // otherwise check if we are connected 
	    if (networkInfo != null && networkInfo.isConnected()) {
	        return true; 
	    } 
	    return false; 
	} 
4
CodeRank
This code example shows how to use the following methods:close
     * @param instance HttpClient 
     */ 
    public static void closeInstance(HttpClient instance) {
        if (instance instanceof AndroidHttpClient) {
            AndroidHttpClient client = (AndroidHttpClient) instance;
            client.close();
        } else { 
            ClientConnectionManager mgr = instance.getConnectionManager();
            if (mgr != null)
                mgr.shutdown();
        } 
    } 
 
    public static void setUserAgentString(String userAgent) {
    	sUserAgent = userAgent;
    } 
     
    public static String getUserAgentString() {
        return sUserAgent;
    } 
4
CodeRank
This code example shows how to use the following methods:close
	} 
	 
	 
	public void endBatch() { 
		this.exec.shutdown();
		this.httpClient.close();
	} 
 
	 
	private class Batch implements Runnable {
		private final URL url;
		 
		private Batch (URL url) {
			this.url = url;
		} 
 
		@Override 
		public void run() { 
			ResponseHandler<StringBuilder> handler = new ResponseHandler<StringBuilder>() {
			    public StringBuilder handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
4
CodeRank

Related AndroidHttpClient close Questions & Answers:

close Method Overview
Release resources associated with this client.
See Code Examples for other Android AndroidHttpClient Methods: