2010-07-31 14 views
0

Android에서 httppost를 통해 PHP 페이지에 연결하고 있습니다. IOException이 발생합니다. localhost에서 실행 중입니다. 이것에 대한 이유는 무엇입니까? 도와주세요. 코드는 다음과 같습니다.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(); 
    } 

답변

2

로컬 호스트 대신 10.0.2.2을 시도하십시오.

관련 문제