Android ByteArrayEntity - 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 ByteArrayEntity class.

This code example shows how to use the following methods:setContentType
      Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null"));
      client                 = constructHttpClient(context, parameters);
      URI targetUrl          = new URI(parameters.getMmsc());
      HttpHost target        = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);
      HttpPost request       = new HttpPost(parameters.getMmsc());
      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());
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setContentType
        callMethod(new HttpGet(feedUrl), operation);
    } 
 
    public void post(String feedUrl, byte[] data, String contentType, Operation operation) throws IOException {
        ByteArrayEntity entity = getCompressedEntity(data);
        entity.setContentType(contentType);
        HttpPost post = new HttpPost(feedUrl);
        post.setEntity(entity);
        callMethod(post, operation);
    } 
 
    public void put(String feedUrl, byte[] data, String contentType, Operation operation) throws IOException {
        ByteArrayEntity entity = getCompressedEntity(data);
        entity.setContentType(contentType);
        HttpPost post = new HttpPost(feedUrl);
        post.setHeader(X_HTTP_METHOD_OVERRIDE, "PUT");
        post.setEntity(entity);
        callMethod(post, operation);
    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setChunked
This code example shows how to use the following methods:setContentEncoding
		HttpClient httpclient = new DefaultHttpClient(); 
		HttpPost post = new HttpPost(url);
		post.setHeader("Content-Type", "application/json");
 
		try { 
		      ByteArrayEntity se = new ByteArrayEntity(json.getBytes());  
		      se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
		      post.setEntity(se);
		       
		      return httpclient.execute(post);
		} 
		catch(Exception e){
			Logger.w("Failed to send request. " +  
		    		Log.getStackTraceString(e));
		} 
		 
		return null; 
	} 
 
	@Override 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                    bos.write(data);
                } 
                data = bos.toByteArray();
                bos.close();
                // UrlEncodedFormEntity entity = getPostParamters(params); 
                ByteArrayEntity formEntity = new ByteArrayEntity(data);
                post.setEntity(formEntity);
                request = post;
            } else if (method.equals("DELETE")) {
                request = new HttpDelete(url);
            } 
            setHeader(method, request, params, url, token);
            HttpResponse response = client.execute(request);
            StatusLine status = response.getStatusLine();
            int statusCode = status.getStatusCode();
 
            if (statusCode != 200) {
                result = read(response);
                String err = null;
                int errCode = 0;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:setContentEncoding, setContentType, getContentLength
This code example shows how to use the following methods:setContentEncoding
		} else { 
			ByteArrayOutputStream arr = new ByteArrayOutputStream();
			OutputStream zipper = new GZIPOutputStream(arr);
			zipper.write(data);
			zipper.close();
			entity = new ByteArrayEntity(arr.toByteArray());
			entity.setContentEncoding("gzip");
		} 
		return entity;
	} 
 
	/** 
	 * Retrieves the minimum size for compressing data. Shorter data will not be 
	 * compressed. 
	 */ 
	public static long getMinGzipSize(ContentResolver resolver) {
		return DEFAULT_SYNC_MIN_GZIP_BYTES; // For now, this is just a constant.
	} 
 
	/* cURL logging support. */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setContentEncoding
        } else { 
            ByteArrayOutputStream arr = new ByteArrayOutputStream();
            OutputStream zipper = new GZIPOutputStream(arr);
            zipper.write(data);
            zipper.close();
            entity = new ByteArrayEntity(arr.toByteArray());
            entity.setContentEncoding("gzip");
        } 
        return entity;
    } 
 
    /** 
     * Retrieves the minimum size for compressing data. 
     * Shorter data will not be compressed. 
     */ 
    public static long getMinGzipSize(ContentResolver resolver) {
        return DEFAULT_SYNC_MIN_GZIP_BYTES;  // For now, this is just a constant.
    } 
 
    /* cURL logging support. */ 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setContentType
		else 
		{ 
			data = EntityUtils.toByteArray( entity );
		} 
 
		ByteArrayEntity bae = new ByteArrayEntity( data );
		if( entity != null )
		{ 
			bae.setContentType( entity.getContentType() );
		} 
		entity = bae;
 
		response.setStatusCode( HttpStatus.SC_OK );
		response.setEntity( entity );
 
	} // handle 
 
} // class EchoHandler 
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android ByteArrayEntity Questions & Answers:

See Code Examples for Android ByteArrayEntity Methods: