Example of Simple Retry Technique to Deal with Timeouts in Android

<div><a href="http://orderessayonlineon.com/">academic writing help online</a> – <a href="http://spyphoneapp-software.com/">software spy phone download</a> – <a href="http://iphonespyapponline.com/">iphone spy</a> – <a href="http://buyessay-onlinein.com/">coursework writing service</a> – <a href="http://cellphonespyappon.com/">spy cell phone voicemail</a> – <a href="http://orderessayonlineon.com/">do my essay for money</a> – <a href="http://cellphonespyappon.com/">cell phone spy iphone free</a></div> import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import […]
Continue reading…

Enjoyed this post? Share it!

 
 

Example of multipart POST using Android

import java.io.ByteArrayInputStream; import java.io.InputStream; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.InputStreamBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; import android.app.Activity; public class TestMultipartPost extends Activity { public void executeMultipartPost()throws Exception { try { InputStream is = this.getAssets().open("data.xml"); HttpClient httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost("http://w3mentor.com/Upload.aspx"); byte[] data = IOUtils.toByteArray(is); InputStreamBody isb […]
Continue reading…

Enjoyed this post? Share it!

 
 

Perform a HTTP POST Request with the HttpClient in Android

HTTP POST calls are made with the HttpClient by calling the execute() method of the HttpClient with an instance of HttpPost. We should pass URL-encoded name/value form parameters as part of the HTTP request. import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; public class TestHttpPost […]
Continue reading…

Enjoyed this post? Share it!

 
 

Example of HTTP GET Request using HttpClient in Android

import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; public class TestHttpGet { public void executeHttpGet() throws Exception { BufferedReader in = null; try { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI("http://w3mentor.com/")); HttpResponse response = client.execute(request); in = new BufferedReader (new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = […]
Continue reading…

Enjoyed this post? Share it!