Android httpPost不工作

Android httpPost不工作,android,android-asynctask,http-post,android-internet,Android,Android Asynctask,Http Post,Android Internet,我正在尝试向某个url发送httpPOST请求。这是我的代码。 我正在使用我在网上找到的异步任务方法 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ne

我正在尝试向某个url发送httpPOST请求。这是我的代码。 我正在使用我在网上找到的异步任务方法

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    new MyHttpPost().execute();

}
private class MyHttpPost extends AsyncTask<String, Void, Boolean> {


        @Override
    protected Boolean doInBackground(String... arg0) 
    {

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://someurl");

            try {
             // Add your data
           List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair(4);
            nameValuePairs.add(new BasicNameValuePair("User", "abcd"));
            nameValuePairs.add(new BasicNameValuePair("email", "1234"));
            nameValuePairs.add(new BasicNameValuePair("password", "abcd"));
            nameValuePairs.add(new BasicNameValuePair("username", "1234"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
           HttpEntity httpEntity = response.getEntity();
           result = httpEntity.getContent();


            } catch (ClientProtocolException e) {
             // TODO Auto-generated catch block
            } catch (IOException e) {
             // TODO Auto-generated catch block
            }
            return true;
    }

    }



 }
然而,在执行应用程序之后,我的服务器数据库没有显示任何点击率。 即使我在添加数据的列表中加了注释,即使是一个空白的httpPost,也没有点击。 请帮忙。紧急。谢谢你的回答。
谢谢

尝试使用标准参数创建DefaultHTTPClient

HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
        HttpVersion.HTTP_1_1);
HttpClient httpClient = new DefaultHttpClient(params);
这对我来说很好

我还使用UTF-8编码设置请求实体:

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));

上述所有代码都可以工作,但我们需要实现对HttpPost的依赖,并进一步与其他服务器(如oracle等)通信。。 依赖项文件是:

编译组:'cz.msebera.android',名称:'httpclient',版本:'4.4.1.1'


此问题解决后

响应消息是什么?你们从服务器上得到了什么?在你们的代码中,你们用自己的url替换了“”,对吗?是的。我使用了一个正确的php脚本url@Damien R.请看一看。我用ResponseHttpPost再次编辑了这个问题。setEntity无法解析您正在使用的库。你能分享一下吗
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));