K
K
kachok2014-05-15 12:05:16
Android
kachok, 2014-05-15 12:05:16

What library to use for asynchronous network requests in android app?

I am learning java and android. I am writing a program that works with an external service via an API.
I found a library for asynchronous requests loopj.com/android-async-http
There are no problems with simple small single requests, but if you try to implement a full-fledged API client, then inefficient places appear, a lot of nested callbacks, parsing the received json in the main application thread, etc. d.
I would like something like this on the click of a button:

void onClick(View v) {
  
  apiClient.getObjects(String param1, new RequestListener() {

    onSuccess(Object result) {
      //тут в result имеем готовый разобранный ответ от сервиса в виде java объекта 
      //причем разбор его был отдельном потоке, так как получаемый от сервиса json может быть большим
    }

    onFailure(Throwable e) {
      //тут ошибка
    }

  });
}

In general, tell me a good example of the implementation of the api-client, and I will do it by analogy.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FoxInSox, 2014-05-15
@FoxInSox

Retrofit

X
xPutnikx, 2014-05-16
@xPutnikx

Google recommends using Volley. https://www.youtube.com/watch?v=yhv8l9F44qo
In my opinion, now this is the best there is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question