HTTP Post Call not working in Android Emulator

1 Comment

Recently I had to call some web service for my development in Android and I used the following method to achieve that

HttpPost httpPost = new HttpPost(url);

ResponseHandler responseHandler = new BasicResponseHandler();

responseText = httpClient.execute(httpPost, responseHandler);

I got the reponseText as expected. After that I did not run the application for sometime. Now when I ran the application today it suddenly stopped working. I got an IOException saying “The target server failed to respond”. I rechecked everything and the web service was still working as expected in a browser. After struggling with lot of options, I changed HttpPost call to HttpGet call and viola, it started working again.

I have no clue why HttpPost call stopped working all of the sudden. It would be helpful if somebody throw some light on the problem.


Enabling Internet Connection Through Proxy in Android in Windows

Leave a comment

Steps for Android 1.5

Following content is referenced from

In the earlier versions of Android emulators (up to version 1.1r2), you were required to make an entry in the system table of“” database and/or start the emulator with –http-proxy switch supplying it the IP address and port number of your proxy.

These methods however, have become obsolete and don’t work with SDKv1.5.
Step 1: On emulator, go to:
Home->Menu->Settings->WirelessControls->MobileNetworks->Access Point Names->T-mobile US->set Proxy IP and Port#

Step 2: Now the next time you go to a web address, the browser will prompt for your user-id and password. Enter your credentials and you should be good to go.

Reference:…d4f948c4ed622#5ced4f948c4ed622” target=”_new” rel=”nofollow”>

Steps for Android 2.2

1) Create an emulator with name say android_2.2_emulator using AVD manager in eclipse.

2) Create a batch file (.bat) with following command and a keep a handy shortcut.

emulator -avd “android_2.2_emulator” -http-proxy “your_proxy_url”:”port”

3) Run the batch file before starting the eclipse IDE, so that the emulator session will have internet connection.

That’s it.

Android – application debug logging

Leave a comment

Following content is referenced from

Here are a couple of places that got me started. First the standard java logging mechanism doesn’t work. In addition System.out.print doesn’t work. You need to use the android.util.log.

import android.os.Bundle;
import android.util.Log;

public class test extends Activity

/** Called with the activity is first created. */
public void onCreate(Bundle icicle)

Log.v(TAG, “onCreate: E”);
Log.v(TAG, “onCreate: X”);

private static final String TAG = “test”;
The Log class supports various levels (VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT) the low-level routine is Log.println(int priority, String tag, String msg). But typically the v, d, i, w, e and a convince routines would be used. So that’s half the game, the other half is to be able to see the output. For that you use “logcat”. In Eclipse if you goto menu “Window/Show View/other/Android/logcat” or if your in the Debug perspective it will be in “Window/Show View/logcat”. Apparently, its not very reliable in Eclipse and executing:

adb logcat

Allows you to see it from a command line, but in Eclipse the log also includes a Date stamp which makes it nice. I was able to get the Eclipse/logcat going by closing than reopening. Of course you mileage may very:) If you look at the links above it appears you can use ddms, but I haven’t used that yet.

Creating Web Application in Android

Leave a comment

The following article talks about creating an offline web application in Android using android.webkit package.