Android Network Framework Retrofit + RxJava + OkHttp changing era

Source: Internet
Author: User

1. What is the retrofit framework?

It is now a very popular network framework developed by Square, so we can see the name of the company when we import its package, the current version is 2.

Characteristics:

Good performance, fast processing, easy to use, Retrofit is one of the most popular HTTP client libraries on Android
Using the rest API design style
Support for NIO (new I/O)
Using OKHTTP to handle network requests by default, I think it can be seen as a okhttp enhancement.

With Google's rejection of the httpclient, and the gradual decline of volley, Okhttp began to rise, while the retrofit of Okhttp was forced to rely on. Retrofit is also a framework developed by Square for Android network requests, which essentially encapsulates the okhttp, uses an interface-oriented approach to network requests, and encapsulates network interfaces with dynamically generated proxy classes. Retrofit is ideal for requests in restful URL formats, and more features are provided using annotations.

Now most of the Android network requests have been replaced by Retrofit2.0 +rxjava + okhttp3.0,retrofit using the interface, responsible for the requested data and the results of the request, OkHttp the process responsible for the request, RxJava is responsible for the asynchronous, Switching between the various threads. There is no doubt that the three Musketeers have become the most popular way of current Android Web requests.

Brief introduction

Retrofit:retrofit is a framework for a restful-style Android network request developed by Square, which provides a layer of encapsulation for okhttp. The network request is still based on the okhttp, we only need to use the retrofit to make the network request through the simple configuration, retrofit official website

Rxjava:rxjava on the GitHub home page, "a library for composing asynchronous and event-based programs using observable sequences for The Java VM "(a library that uses observable sequences on a Java VM to compose an asynchronous, event-based program). In summary, Rxjava makes asynchronous operations very simple. RxJava

Okhttp:square Company Open-Source Network Request Library OkHttp

Basic use

The HTTP protocol defines eight methods or "actions" to indicate the different modes of operation of the resources specified by the Request-uri, namely options, HEAD, GET, POST, PUT, DELETE, TRACE, CONNECT, which are omitted.

Although there are so many requests, but the app's interface request is nothing more than the data deletion and modification, adding and removing changes to the RESTful style interface is post,delete,put,get four kinds of requests. In the annotations provided by the retrofit framework, there are five HTTP annotations, which are used to decorate the request method, except that Post,delete,put,get has a head. In addition to these five types of network requests, the app will use only retrofit single file or multiple file upload and download, synchronous request or asynchronous request processing, and okhttp data cache problem.

Ref: 73732076

The retrofit of the Android network framework + RxJava + OkHttp Change era

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.