Android AndroidHttpClient - top ranked examples from Open Source projects

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

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
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getPackageManager, getPackageName, getString, newInstance
	} 
 
	private <T> T doRequest(HttpRequestBase request, ResponseHandler<T> responseHandler) {
		mHttpRequest = request;
 
		AndroidHttpClient client = AndroidHttpClient.newInstance(getUserAgent(), mContext);
		AndroidHttpClient.modifyRequestToAcceptGzipResponse(mHttpRequest);
 
		HttpParams httpParameters = client.getParams();
		HttpConnectionParams.setSoTimeout(httpParameters, 100000);
 
		try { 
			return client.execute(mHttpRequest, responseHandler);
		} 
		catch (IOException e) {
			Log.e("Server request failed.", e);
		} 
		finally { 
			client.close();
		} 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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) {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getParams
    private final AndroidHttpClient mHttpClient;
 
    public OpenSearchSearchEngine(Context context, SearchEngineInfo searchEngineInfo) {
        mSearchEngineInfo = searchEngineInfo;
        mHttpClient = AndroidHttpClient.newInstance(USER_AGENT);
        HttpParams params = mHttpClient.getParams();
        params.setLongParameter(HTTP_TIMEOUT, HTTP_TIMEOUT_MS);
    } 
 
    public String getName() {
        return mSearchEngineInfo.getName();
    } 
 
    public CharSequence getLabel() {
        return mSearchEngineInfo.getLabel();
    } 
 
    public void startSearch(Context context, String query, Bundle appData, String extraData) {
        String uri = mSearchEngineInfo.getSearchUriForQuery(query);
        if (uri == null) {
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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;
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android AndroidHttpClient Questions & Answers:

See Code Examples for Android AndroidHttpClient Methods: