开发者

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 Defaul开发者_StackOverflow社区tHttpClient();
    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();
    }


Try 10.0.2.2 instead of localhost.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜