Android:如何解决<namevaluepair>,BasicNameValuePair,HTTPParams,HttpConnectionParams

时间:2016-07-15 12:35:09

标签: java android android-studio

protected Void doInBackground(Void... params) {
        //server able to receive it
        ArrayList<NameValuePair> dataToSend = new ArrayList<>();
        dataToSend.add(new BasicNameValuePair("username", user.username));
        dataToSend.add(new BasicNameValuePair("password", user.password));

        HttpParams httpRequestParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpRequestParams, CONNECTION_TIMEOUT);
        HttpConnectionParams.setSoTimeout(httpRequestParams, CONNECTION_TIMEOUT);

        HttpClient client = new DefaultHttpClient(httpRequestParams);
        HttpPost post = new HttpPost(SERVER_ADDRESS + "Register.php");

        post.setEntity();

        return null;
    }

1 个答案:

答案 0 :(得分:0)

build.gradle(Module:app)中的useLibrary,例如:

 defaultConfig {
        applicationId "com.example.softwareengineer.robot"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        useLibrary 'org.apache.http.legacy'
 }