2012-05-21 137 views
4

我試圖用android連接mysql,但它會給我一個錯誤。 錯誤HTTP連接的java.net.UnknownHostException:Android - HTTP連接錯誤java.net.UnknownHostException:

下面是我的代碼:

HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost("http://www.pherma.net84.net/admin/getAllPeopleBornAfter.php"); 
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
HttpResponse response = httpclient.execute(httppost); 
HttpEntity entity = response.getEntity(); 

但URL s工作的罰款。請複製n貼上網址。

+3

設備的網絡連接是否正常工作?你有沒有在你的AndroidManifest中指定'internet'權限? – Floern

+0

刪除此行httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); –

+0

它的作品現在...我的壞....沒有給予網絡的許可 –

回答

4

我忘了將網絡權限放入清單。現在工作正常。