Answer the question
In order to leave comments, you need to log in
How to get a list of random users?
It is required to get a list of random users. I use Retrofit and API from Github.
final Call<List<GithubUser>> call = service.getListOfUsers(new Random().nextInt(50));
call.enqueue(new Callback<List<GithubUser>>() {
@Override
public void onResponse(Call<List<GithubUser>> call, Response<List<GithubUser>> response) {
if (response.isSuccessful()) {
//get user from response.body by random id
} else {}
}
@Override
public void onFailure(Call<List<GithubUser>> call, Throwable t) {}
});
//описание запроса в apiInterface
@GET("/users?since")
Call<List<GithubUser>> getListOfUsers(@Query("number") int number);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question