mercredi 13 juillet 2016

Best practice to get json from url in api 23

I'm using compileSdk 23 with support library version 23.

I've used httplegacy library (I've copied it into app/libs folder from androidSdk/android-23/optional/org.apache.http.legacy.jar) and in gradle I've put:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

In order to load that library.

Into my Connection class I've got a method to load an instance of DefaultHttpClient in this way:

private static HttpClient getClient(){
    HttpParams httpParameters = new BasicHttpParams();
    int timeoutConnection = 3000;
    HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
    int timeoutSocket = 3000;
    HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

    DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);

    return httpClient;
}

But Android Studio says me that all apache.http classes are deprecated.

What could I use in order to follow best practice?

Aucun commentaire:

Enregistrer un commentaire