使用JSON将数据发送到您的PHP脚本。 通过组合
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
来源:http://www.androidsnippets.com/executing-a-http-post-request-with-httpclient
,寻找关于JSON,你应该能够做到你想要
与setEntity我得到的URL像mailScript?id = 12345&stringdata = AndDev_Is_Cool! ?? – Raicerda 2012-01-18 12:37:29