使用Android中的HttpPost请求将数据发送到服务器

时间:2013-07-26 07:23:32

标签: android http-post httpclient

我将字符串值发送到服务器上的php文件,如下所示:

    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("serverurl");
    Log.d("httppost..", httppost + "");
    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("data", dataCount + ""));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
    }

但是,我没有看到我从应用程序发送的任何数据。 谢谢你的帮助。

0 个答案:

没有答案