2016-07-15 4 views
0
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; 
    } 
+0

https://stackoverflow.com/questions/32949626/org-apache-http- entity-filentity-is-deprecated-in-android-6-marshmallow – CommonsWare

+0

besser ist es nicht zu verwenden 'Apache HttpClient' .. es ist im Ruhestand ... verwenden Sie HttpURLConnection oder andere Bibliotheken. – Bharatesh

Antwort

0

useLibrary in build.gradle(Module:app), ex:

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

DefaultConfig {useLibrary 'org.apache.http.legacy'} –

+0

hinzufügen httpClient.jar Datei in den Ordner libs und die JAR-Datei in build.gradle laufen (Modul: app) schreiben useLibrary 'org.apache.http.legacy' kompilieren 'org.apache.httpcomponents: httpcore: 4.4.1' compile 'org.apache.httpcomponents: httpclient: 4.5' –

Verwandte Themen