简体   繁体   English

Android okhttp库

[英]Android okhttp library

To use OkHttp in a Gradle build, I need to add the following dependency to the Gradle build. 要在Gradle构建中使用OkHttp,我需要在Gradle构建中添加以下依赖项。

compile 'com.squareup.okhttp:okhttp:2.5.0' 

Does that mean I am using okhttp-urlconnection module which implements the familiar java.net.HttpURLConnection API OR the okhttp-apache module which implements the Apache HttpClient API? 这是否意味着我使用的是实现熟悉的java.net.HttpURLConnection API的okhttp-urlconnection模块,或者是实现了Apache HttpClient API的okhttp-apache模块?

Have you copied Lines? 您复制行了吗? :) :) :) :)

Documentations Says: 文档说:

You can try out OkHttp without rewriting your network code. 您可以尝试OkHttp而不用重写网络代码。 The okhttp-urlconnection module implements the familiar java.net.HttpURLConnection API and the okhttp-apache module implements the Apache HttpClient API . okhttp-urlconnection模块实现了熟悉的java.net.HttpURLConnection API,而okhttp-apache模块实现了Apache HttpClient API

OkHttp supports Android 2.3 and above. OkHttp支持Android 2.3及更高版本。 For Java, the minimum requirement is 1.7. 对于Java,最低要求为1.7。

It means you can use this library classes. 这意味着您可以使用此库类。 I have used this library with retrofit. 我已经对该库进行了改造。

import com.squareup.okhttp.OkHttpClient;
OkHttpClient okHttpClient = new OkHttpClient();
RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint(ContextConstants.REPORT_SUBMIT_PATH)
            .setClient(new OkClient(okHttpClient))
            .build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM