LoopJ AndroidAsyncHttp

时间:2015-09-25 09:30:21

标签: android android-async-http

我是网络方面的新手,想要了解LoopJ AndroidAsyncHttp是如何工作的,我已经下载了项目并在构建之后使其工作。 现在我对LoopJ AndroidAsyncHttp的任何链接或教程都很熟悉,以便在我开始浏览项目代码之前获得基本的想法。

我也在学习android,所以我很难在不了解基础知识的情况下理解代码。

请指导我选择更好的方法来理解它。

我的工作项目是:https://github.com/loopj/android-async-http

2 个答案:

答案 0 :(得分:0)

使用OkHttp

 Let me show a simple example.

import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import java.io.IOException;

public class GetExample {
OkHttpClient client = new OkHttpClient();

String run(String url) throws IOException {
Request request = new Request.Builder()
    .url(url)
    .build();

Response response = client.newCall(request).execute();
return response.body().string();
}

 public static void main(String[] args) throws IOException {
 GetExample example = new GetExample();
 String response =    example.run("https://raw.github.com/square/okhttp/master/README.md");
 System.out.println(response);
 }
}

答案 1 :(得分:0)

与NaviRamyle所说,您可以使用Retrofit作为异步HTTP请求的解决方案。另外,请查看Google的排球。一个很好的示例/教程让我使用和享受Volley是Androidhive的基本Volley教程:

exception

默认情况下,所有请求都是异步的,并由您可以在应用程序上轻松实现的回调体系结构进行管理。

致以最诚挚的问候,