SlideShare a Scribd company logo
Retrofit 2.0
KRISTIJAN JURKOVIC
WHAT IS RETROFIT?
USAGE
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
WHAT’S DIFFERENT?
com.squareup.retrofit > com.squareup.retrofit2
Converters
Rest interface methods return Call<T>
OkHttp is required
Security exception if no Internet permission
RestAdapter > Retrofit
CALL<T>
call.enqueue(new Callback<T> { … })
call.execute();
call.cancel();
ONRESPONSE
response.isSuccess();
response.code();
response.body();
response.errorBody().string();
URL HANDLING
same as web <a href=“…” /> handling
@GET(“blog”)
Base url: http://www.infinum.co/api/v1
Result: http://www.infinum.co/api/blog
Base url: http://www.infinum.co/api/v1/
Result: http://www.infinum.co/api/v1/blog
URL HANDLING
@GET(“/blog”)
Base url: http://www.infinum.co/api/v1
Result: http://www.infinum.co/blog
@GET(“http://www.infinum.co/api/v1/blog”)
@GET
void get(@Url String url);
LOG
CONVERTERS
.addConverterFactory({pass in converter here});
Gson: com.squareup.retrofit:converter-gson
Jackson: com.squareup.retrofit:converter-jackson
Moshi: com.squareup.retrofit:converter-moshi
Protobuf: com.squareup.retrofit:converter-protobuf
Wire: com.squareup.retrofit:converter-wire
Simple XML: com.squareup.retrofit:converter-simplexml
Converter.Factory interface
CONVERTERS
.addConverterFactory({pass in converter here});
Gson gson = new GsonBuilder()
... add type converters here
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(“http://www.infinum.co/api/”)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
Any questions?
KRISTIJAN.JURKOVIC@INFINUM.CO
@KJURKOVIC
Visit infinum.co or find us on social networks:
infinum.co infinumco infinumco infinum

More Related Content

PPTX
Retrofit 2 - O que devemos saber
PDF
Android Libs - Retrofit
PDF
Retrofit
DOCX
Client server part 12
PPTX
Retrofit Technology Overview by Cumulations Technologies
PDF
Retro vs volley (2)
PDF
Extending Retrofit for fun and profit
PPT
Pemrograman Jaringan
Retrofit 2 - O que devemos saber
Android Libs - Retrofit
Retrofit
Client server part 12
Retrofit Technology Overview by Cumulations Technologies
Retro vs volley (2)
Extending Retrofit for fun and profit
Pemrograman Jaringan

What's hot (20)

PDF
Service Oriented Web Development with OSGi - C Ziegeler
PPTX
Sensu wrapper-sensu-summit
PDF
Asynchronen Code testen
PDF
Easy REST APIs with Jersey and RestyGWT
PPTX
My sql failover test using orchestrator
PPTX
MySQL Monitoring using Prometheus & Grafana
PDF
How to send gzipped requests with boto3
PPTX
Behind modern concurrency primitives
PDF
NestJS
PDF
Spark Day 2017- Spark 의 과거, 현재, 미래
PDF
Nestjs MasterClass Slides
PDF
Source Plugins
PDF
Crawler 2
PDF
Analysing Github events with Neo4j
PDF
Programação Assíncrona com Asyncio
PDF
Mobile Programming - Network Universitas Budi Luhur
PDF
Mobile Programming - 3 UDP
PDF
Making the most of your gradle build - Gr8Conf 2017
PDF
Making the most of your gradle build - Greach 2017
PPTX
StackExchange.redis
Service Oriented Web Development with OSGi - C Ziegeler
Sensu wrapper-sensu-summit
Asynchronen Code testen
Easy REST APIs with Jersey and RestyGWT
My sql failover test using orchestrator
MySQL Monitoring using Prometheus & Grafana
How to send gzipped requests with boto3
Behind modern concurrency primitives
NestJS
Spark Day 2017- Spark 의 과거, 현재, 미래
Nestjs MasterClass Slides
Source Plugins
Crawler 2
Analysing Github events with Neo4j
Programação Assíncrona com Asyncio
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - 3 UDP
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Greach 2017
StackExchange.redis
Ad

Viewers also liked (19)

PDF
Retro vs Volley
PPTX
introduce Okhttp
PDF
Simplificando chamadas HTTP com o Retrofit
PDF
Retrofit
PDF
Realm @Android
PDF
Android DevConference - Dagger 2: uso avançado em projetos Android
PDF
Reactive programming on Android
PPTX
大鱼架构演进
PDF
Reactive programming with RxJava
PPTX
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
PDF
Java Libraries You Can’t Afford to Miss
PDF
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
PDF
Practical RxJava for Android
PDF
RxJava - introduction & design
PDF
Reactive programming on Android
PDF
Seismic retrofit methods
PPTX
Reactive Programming on Android - RxAndroid - RxJava
PDF
Java 8 Stream API and RxJava Comparison
PDF
Staying Afloat with Buoy: A High-Performance HTTP Client
Retro vs Volley
introduce Okhttp
Simplificando chamadas HTTP com o Retrofit
Retrofit
Realm @Android
Android DevConference - Dagger 2: uso avançado em projetos Android
Reactive programming on Android
大鱼架构演进
Reactive programming with RxJava
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Java Libraries You Can’t Afford to Miss
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Practical RxJava for Android
RxJava - introduction & design
Reactive programming on Android
Seismic retrofit methods
Reactive Programming on Android - RxAndroid - RxJava
Java 8 Stream API and RxJava Comparison
Staying Afloat with Buoy: A High-Performance HTTP Client
Ad

Similar to Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic (13)

PPTX
Firebase, Jetpack, Retrofit.pptx
PPTX
Não reinvente a roda! Desenvolvendo com bibliotecas Android
PPTX
Using Retrofit framework in implementation of Android REST client (Presentation)
PDF
Introduction to Retrofit
PDF
Android Performance #4: Network
PDF
RetroFit by Square - GDG Dallas 06/09/16
PDF
Making Java REST with JAX-RS 2.0
PDF
Infinum Android Talks #01 - Retrofit
PPTX
Performance #4 network
PDF
Lab 5-Android
PDF
Android: a full-stack to consume a REST API
PDF
Android application architecture
PDF
Modern Android app library stack
Firebase, Jetpack, Retrofit.pptx
Não reinvente a roda! Desenvolvendo com bibliotecas Android
Using Retrofit framework in implementation of Android REST client (Presentation)
Introduction to Retrofit
Android Performance #4: Network
RetroFit by Square - GDG Dallas 06/09/16
Making Java REST with JAX-RS 2.0
Infinum Android Talks #01 - Retrofit
Performance #4 network
Lab 5-Android
Android: a full-stack to consume a REST API
Android application architecture
Modern Android app library stack

More from Infinum (20)

PDF
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
PDF
Infinum Android Talks #20 - DiffUtil
PDF
Infinum Android Talks #20 - Benefits of using Kotlin
PDF
Infinum iOS Talks #4 - Making our VIPER more reactive
PDF
Infinum iOS Talks #4 - Making your Swift networking code more awesome with Re...
PDF
Infinum Android Talks #13 - Using ViewDragHelper
PDF
Infinum Android Talks #14 - Log4j
PDF
Infinum Android Talks #9 - Making your app location-aware
PDF
Infinum Android Talks #14 - Gradle plugins
PDF
Infinum Android Talks #14 - Facebook for Android API
PDF
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
PDF
Infinum Android Talks #18 - Create fun lists by Ivan Marić
PDF
Infinum Android Talks #18 - In-app billing by Ivan Marić
PDF
Infinum Android Talks #18 - How to cache like a boss by Željko Plesac
PDF
Infinum iOS Talks #2 - VIPER for everybody by Damjan Vujaklija
PDF
Infinum iOS Talks #2 - Xamarin by Ivan Đikić
PDF
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
PDF
Infinum iOS Talks #1 - Swift done right by Ivan Dikic
PDF
Infinum iOS Talks #1 - Becoming an iOS developer swiftly by Vedran Burojevic
PDF
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
Infinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - Benefits of using Kotlin
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum iOS Talks #4 - Making your Swift networking code more awesome with Re...
Infinum Android Talks #13 - Using ViewDragHelper
Infinum Android Talks #14 - Log4j
Infinum Android Talks #9 - Making your app location-aware
Infinum Android Talks #14 - Gradle plugins
Infinum Android Talks #14 - Facebook for Android API
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
Infinum Android Talks #18 - Create fun lists by Ivan Marić
Infinum Android Talks #18 - In-app billing by Ivan Marić
Infinum Android Talks #18 - How to cache like a boss by Željko Plesac
Infinum iOS Talks #2 - VIPER for everybody by Damjan Vujaklija
Infinum iOS Talks #2 - Xamarin by Ivan Đikić
Infinum iOS Talks #1 - Swift under the hood: Method Dispatching by Vlaho Poluta
Infinum iOS Talks #1 - Swift done right by Ivan Dikic
Infinum iOS Talks #1 - Becoming an iOS developer swiftly by Vedran Burojevic
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
System and Network Administration Chapter 2
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
L1 - Introduction to python Backend.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Digital Strategies for Manufacturing Companies
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
history of c programming in notes for students .pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
top salesforce developer skills in 2025.pdf
ManageIQ - Sprint 268 Review - Slide Deck
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administration Chapter 2
Upgrade and Innovation Strategies for SAP ERP Customers
L1 - Introduction to python Backend.pptx
How Creative Agencies Leverage Project Management Software.pdf
Introduction to Artificial Intelligence
Design an Analysis of Algorithms II-SECS-1021-03
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Online Work Permit System for Fast Permit Processing
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Which alternative to Crystal Reports is best for small or large businesses.pdf
Odoo POS Development Services by CandidRoot Solutions
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Digital Strategies for Manufacturing Companies
CHAPTER 2 - PM Management and IT Context
history of c programming in notes for students .pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic