-1
我創建了一個將數據發送到web的android程序。垃圾郵件不能正常工作
這裏是我的代碼:
public void sendToweb() {
// get the message from the message text box
String msg = systemId1.getText().toString();
// make sure the fields are not empty
if (msg.length() > 0) {
HttpResponse response = null;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://eservices.rondssolar.com/xbusiness.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
2);
nameValuePairs.add(new BasicNameValuePair("submit", "Save Tracker Data"));
nameValuePairs.add(new BasicNameValuePair("systemId", msg));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
Toast.makeText(getApplicationContext(),
"DATA SEND" + response.getStatusLine().toString(),
Toast.LENGTH_LONG).show();
} catch (ClientProtocolException e) {
Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
} catch (IOException e) {
Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
}
} else {
// display message if text fields are empty
Toast.makeText(getBaseContext(), "All field are required",
Toast.LENGTH_SHORT).show();
}
}
我的問題是,我沒有得到任何迴應back.Also我送不可在網上。我覺得我的回答= httpclient.execute數據(httppost );代碼不工作
您從UI線程做到這一點?並沒有得到錯誤?或者你如何使用這種方法?如果有錯誤,請添加logcat。 –
我簡單地從菜單 – user3197627
調用這個方法所以沒有錯誤,什麼都沒有發生? –