Detailed tutorial on how to use Retrofit, and how to use retrofit
1. What is the fit framework?
It is a very popular network framework developed by Square, so we can see its name when importing its package. The current version is 2.
Features:
High performance, fast processing, and easy to use. Retrofit is one of the m
This tutorial is based on the retrofit1.9 version and Android platform.Prepare:Retrofit: Https://github.com/square/retrofitIf you introduce a jar package, you also introduce additional retrofit dependent jar packages.Because the retrofit1.9 version no longer supports Android native URLConnection and httpclient frameworks. The okHttp2.0 framework must be introduced for network access. The following 2 are nec
can be dynamically passed in when this method is called.}Synchronous and asynchronousThe method that has the return value is executed synchronously.@GET ("/user/{id}/photo") Photo Getuserphoto (@Path ("id") int id);If you want to use asynchronous execution, the last parameter to the method is callback.Interface asychronousclient{@GET ("/") void GetResponse (callbackOn the Android platform, the statements in callbacks are executed on the main thread. (the part of the network access is executed i
}/photo")
observable1 2
1 2Now you can do a lot of things, not only to get the data but also to change the data.Retrofit support for observable makes it easy to combine multiple rest calls together. For example, we have a call to get a photo, a second call to get the native data, and we can package the results together.Observable.zip (
Service.getuserphoto (ID),
service.getphotometadata (ID),
(photo, metadata), Createphotowithdata (photo, metadata))
. Subscribe (Photowithdata-Sho
ObjectiveFrom the work of square company of mobile payment company, the smallest company of open source World top5, first I myself is a loyal square powder, okhttp, Picasso, Greendao, Okio and so on ~According to the square CTO Bob Lee, Square has submitted more than 60 projects to the open source community, contributing around 250,000 lines of code.Original: Retrofit 2.0:the biggest update yet on the best HTTP Client Library for AndroidBecause of its
In the face of a project, I think of three options for Android application Development framework:1. The use of loader + httpclient + Greendao + Gson + Fragment, the advantage is a strong customization, because of the use of Google's own loader and Loadermanager, strong code robustness.The disadvantage is that the whole set of code learning costs are high, the use of the process Model code more, (for example, each request will need to produce a new class)2.Volley, as Google in the IO Conference o
RESTful style interface has become the mainstream of the industry, retrofit framework also fire special fire, the recent project also decided to upgrade, the use of retrofit. In the spirit of learning, but also to the next learners have some help, so wrote this article, the main content of the official website of the content of a translation and supplementary explanations.Plus: This article assumes that you
Retrofit: Type-safe REST Client for Android java Monday, May 5, 201421:11Official website: http://square.github.io/retrofit/ GitHub Address: https://github.com/square/retrofit JavaDocs Address: http://square.github.io/retrofit/javadoc/index.html This essay is a translation of the official website
Https://futurestud.io/blog/retrofit-getting-started-and-android-clientRetrofit Series Overview
Getting Started and Create an Android Client
Basic Authentication on Android
Token Authentication on Android
OAuth on Android
Multiple Query Parameters of same Name
Synchronous and asynchronous requests
Send Objects in Request Body
Define a Custom Response Converter
ADD Custom Request Header
Optional Query Parameters
How to integrate
1. PrefaceThis article is based on the use of Rxjava, retrofit, if the Rxjava or retrofit do not understand the Jianyo can first understand the Rxjava, retrofit usage and then see this article.The use of Rxjava and retrofit was described separately before this article:
Use of Android
Retrofit is an HTTP client access framework that can be applied to Android and Java by Square, and its underlying application is okhttp.In this post, we take the following HTTP request as an example:HTTPS://Api.github.com/users/basil2styleThe result of the request (JSON) is as follows:{ "Login": "Basil2style", "id": 1285344, "Avatar_url": "Https://avatars.githubusercontent.com/u/1285344?v=3", "gravatar_id": "", "url": "Https://api.github.com/user
I was wondering if I could change the network request from my previous project.Want to pass retrofit refactoring, because retrofit is perfectly compatible with Rxjava back will be used RxjavaSoOpen a hole and write.As the architecture of online retrofit 2.0 is described in detail. So I'm just here to provide some of the problems and solutions I've encountered.To
Type-Safe HTTP client for retrofit:android and Java.Introduction:1.Retrofit Convert your HTTP API to Java interface2.Retrofit class to implement the Githubservice interface3. Each call to create Githubservice can be synchronous or asynchronous to request a remote network serveruse annotations to describe HTTP requests:1. Support URL parameter substitution and query parameters2. Object is converted to the re
This article is not original, but probably translated Retrofit English documents, right as their own notes only.English Original address: http://square.github.io/retrofit/1. IntroductionRetrofit Convert your HTTP API to a Java interface.1 Public Interface Githubservice {2 @GET ("/users/{user}/repos")3 Call) String user); 4 }Retrofit generates an implementati
Retrofit Introduction:Retrofit (GitHub homepage https://github.com/square/okhttp) and Okhttp division, also square Open Source Library, it is a type of secure network request library, Retrofit simplifies the network request process, based on okhtttp encapsulation, decoupling is more thorough: for example, through annotations to configure request parameters, through the factory to generate Calladapter,conver
Time relationship, this article on the simple use of Retrofit 2.0 to explain as to the principle after the free to analyzeThe project is comprehensive, simple and easy to understand address:The simple use of Retrofit 2.0 is as follows: Https://gitee.com/bimingcong/MyRetrofitPrivate voidInitget () {Retrofit Retrofit=New
Retrofit is a very useful HTTP calling component. The built-in is actually okhttp. Encapsulate the okhttp to make daily business interactions less aware of HTTP calls.An HTTP call requires just one line of code. The use of specific retrofit is not explained here. Self-Baidu.This explains only how to enable retrofit to print related parameter logs for HTTP calls.
simple use of retrofit and RxjavaRetrofit is a network request tool after two encapsulation of the base and okhttp framework, if used alone as a network request, I think there is not much difference with xutils, volley, okhttp, just volley in the method of returning the parameter after the request, This method can be directly UI update, do not need to handler notify the main thread, because it is the thread is the main threads, so for xutils and Okhtt
Retrofit is a network service library developed by SquareThe returned data returned by the HTTP protocol based API can be converted to Java objects for easy operation .
Public interface Netservice {
@GET ("Server/{param}/api")//Request URL in Get (SERVER/{PARAM}/API) >>>> Note that the URL here is generally not a complete URL, but the latter part of the entire URL, generally there is a base_url> later
//where the {} Surrounded by the part is an i
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.