Sunday, June 16, 2013

HTTP Requests in Android

This code executes a HTTP POST request with org.apache.http.client.HttpClient. Could be used in combination with "Non-Blocking Web Requests". public void postData() {     // Create a new HttpClient and Post Header     HttpClient httpclient = new DefaultHttpClient();     HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");     try {         // Add your data  ...

Setting up the Android Emulator for HTTP debugging using Fiddler2

Launch an emulator with parameters: emulator -avd my_avd -http-proxy 127.0.0.1:8888 http://www.android-proxy.com/2011/11/may-force-be-with-you-use.html Finding proxy: DefaultHttpClient httpclient = new DefaultHttpClient(); String proxyString = Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.HTTP_PROXY); if (proxyString != null) { String proxyAddress = proxyString.split(":")[0]; int proxyPort = Integer.parseInt(proxyString.split(":")[1]); HttpHost proxy = new HttpHost(proxyAddress, proxyPort); ...

Powered by Blogger.