James
James

Reputation: 14101

IO Error in Android

I am connecting to a php page via httppost in Android. I am getting an IOException. I am running in localhost. What is the reason for this? Please help. The code is like this.

    htClient = new DefaultHttpClient();
    httpPost = new HttpPost("http://localhost/form/android_test.php");
    response = new BasicResponseHandler();
    try
    {           
        result = htClient.execute(httpPost,response);
        Toast.makeText(active.this,result, Toast.LENGTH_SHORT).show();
    } 
    catch (ClientProtocolException e) {

        Toast.makeText(active.this,e.getMessage(), Toast.LENGTH_SHORT).show();
    } 
    catch (IOException e) {
    // i am always getting this exception.  
         Toast.makeText(active.this,"IO Error " + e.getMessage(), Toast.LENGTH_LONG).show();
    }

Upvotes: 0

Views: 344

Answers (1)

JRL
JRL

Reputation: 78003

Try 10.0.2.2 instead of localhost.

Upvotes: 2

Related Questions