2
我試圖從android應用程序(帶模擬器)發送數據到web服務器(一個php頁面)時下。首先,我曾用模擬器嘗試過這個程序,並且它已經成功運行。在那之後,我試過此程序電話,但出現異常:超時異常(從Android發送數據到PHP頁面)
- > IO例外:操作超時。我的代碼
第一部分:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.33:90/takeDatas.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("enlem", latitude));
nameValuePairs.add(new BasicNameValuePair("boylam", longitude));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
} catch (ClientProtocolException e) {
Toast.makeText(ReportLocationActivity.this, "Client protokol exception ", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(ReportLocationActivity.this, "IO exception "+e.getMessage(), Toast.LENGTH_LONG).show();
}
我希望你能幫助我。 在此先感謝。
您的手機是否接收數據 – zode64 2011-12-13 20:23:26
不,我只看到這個例外。 – iremce 2011-12-13 20:38:02