Retrofit入门
1 Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(ScalarsConverterFactory.create()) //请求返回字符串,如需返回对象,需使用converter-gson
.baseUrl("http://www.baidu.com").build();
DataService service = retrofit.create(DataService.class);
public interface DataService {
@GET("/")
Call<String> getData();
}
Call<String> data = service.getData();
//String msg=data.execute().body().toString();//同步执行 //异步执行
data.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) { }
@Override
public void onFailure(Call<String> call, Throwable t) { }
});
- Gson:
com.squareup.retrofit2:converter-gson
- Jackson:
com.squareup.retrofit2:converter-jackson
- Moshi:
com.squareup.retrofit2:converter-moshi
- Protobuf:
com.squareup.retrofit2:converter-protobuf
- Wire:
com.squareup.retrofit2:converter-wire
- Simple XML:
com.squareup.retrofit2:converter-simplexml
- Scalars (primitives, boxed, and String):
com.squareup.retrofit2:converter-scalars
Retrofit入门的更多相关文章
- Retrofit 入门学习
Retrofit 入门学习官方RetrofitAPI 官方的一个例子 public interface GitHubService { @GET("users/{user}/repos&qu ...
- Retrofit 入门和提高
首先感谢这个哥们,把我从helloworld教会了. http://blog.csdn.net/angcyo/article/details/50351247 retrofit 我花了两天的时间才学会 ...
- Android开发 retrofit入门讲解 (RxJava模式)
前言 retrofit除了正常使用以外,还支持RxJava的模式来使用,此篇博客讲解如何使用RxJava模式下的retrofit 依赖 implementation 'com.squareup.ret ...
- Android开发 retrofit入门讲解
前言 retrofit基于okhttp封装的网络请求框架,网络请求的工作本质上是 OkHttp 完成,而 retrofit 仅负责网络请求接口的封装.如果你不了解OKhttp建议你还是先了解它在来学习 ...
- Retrofit 从入门到了解【总结】
源码:https://github.com/baiqiantao/RetrofitDemo.git 参考:http://www.jianshu.com/p/308f3c54abdd Retrofit入 ...
- Retrofit 简介 wiki 文档
简介 Type-safe HTTP client for Android and Java by Square, Inc. GitHub主页:https://github.com/square/ret ...
- Android开发 retrofit下载与上传
前言 此博客只讲解retrofit下载与上传的使用,其实与其说是retrofit的下载与上传还不如说,依然是Okhttp的下载与上传.如果你需要了解retrofit入门请查看这篇博客(此博客不在详细讲 ...
- code style
http://www.jianshu.com/p/0a984f999592# https://github.com/drakeet/LayoutFormatter https://github.com ...
- Android进阶:七、Retrofit2.0原理解析之最简流程【上】
retrofit 已经流行很久了,它是Square开源的一款优秀的网络框架,这个框架对okhttp进行了封装,让我们使用okhttp做网路请求更加简单.但是光学会使用只是让我们多了一个技能,学习其源码 ...
随机推荐
- C#继承的用法
using System; namespace 继承 { public class cat { private string _name = null; private int _age = 0; p ...
- Spring中IoC的入门实例
Spring中IoC的入门实例 Spring的模块化是很强的,各个功能模块都是独立的,我们可以选择的使用.这一章先从Spring的IoC开始.所谓IoC就是一个用XML来定义生成对象的模式,我们看看如 ...
- mongoDB数据库备份
mongodump -h dbhost -d dbname -o dbdirectory 备份mongoDB数据库 重新打开 dos命令框 mongodump -h 127.0.0.1:27017 - ...
- Windows 32 程序设计
C语言版 开发语言:C语言 开发工具:Visual Studio 2015 目 标:使用C语言,直接调用Windows API,创建Windows程序. 参考图书:<Windows程序 ...
- winform窗体的关闭与资源的释放
单纯的this.Dispose(); this.Close();有时候并不能释放出所用资源.因为Dispose()方法,虽然能释放当前窗体的资源,却不能强制结束循环, 要想强制突出当前程序要用:Sy ...
- linux内核hash list
源码: #ifndef _LINUX_HLIST_H #define _LINUX_HLIST_H /* * Double linked lists with a single pointer lis ...
- cmd 登录oracle
源地址:http://zhidao.baidu.com/link?url=mehN7bFY14DGH6DwhpbJnAbzb_fI3WbQn2-WqVInyyqHkfYlZSfu7GQVjQgQoPV ...
- Ulipad和有道词典冲突的问题
Ulipad和目前版本的有道词典有冲突,表现为先开有道词典,Ulipad就无法运行. 解决方法是:找到Ulipad安装目录下的config.ini,添加以下两行: [server] port=50 ...
- struts2 使用注解方式配置
1.导入convention 包 2.java: package com.struts.base.hello; import java.io.IOException; import java.io.P ...
- android 列表开发 ListView
1.android 端 二个entity consultInfo: private String name; private String id; consultInfoRef private iLi ...