2010-07-31 70 views
0

我正在通過Android中的httppost連接到一個php頁面。我得到一個IOException。 我在本地主機上運行。這是什麼原因?請幫忙。代碼是這樣的。Android中的IO錯誤

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(); 
    } 

回答