SlideShare a Scribd company logo
Using Retrofit framework in implementation of
Android REST client
David Ante Macan*, Zlatko Stapić, Milan Pavlović*
University of Zagreb
Faculty of Organization and Informatics
Pavlinska 2, 42000 Varaždin, Croatia
http://www.foi.unizg.hr/
CASE27 – Developers conference - 02.06.2015. – Zagreb, Croatia
* Students at University of Zagreb, FOI Varazdin
Agenda
• Introduction
• REST Architecture
• Android client implementation
• Implementation using Retrofit
• Conclusion
• References
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20152
Introduction
• Today’s mobile applications are Internet dependent
• 2017 -> 90% [1], [3]
• Web services are used for supporting mobile application
functionalities
 Internet dependent monetization models
 App usage statistics, data synchronization, social components, score
tables…
• Backend servers for push notifications
• Web service – self contained and self describing application
component that can be used by other applications and can be
communicated by using open protocols [6]
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20153
Introduction
• After SOA became widely used for mobile and other applications,
the dominant way of exchanging the data with web services was
by using SOAP [7]
• XML used for creating requests and responses was too complex
and requests had to be build manually -> problematic due to
protocols intolerance on any errors
• REST (Representational State Transfer) provides lightweight
alternative and relies on simple URL approach
• REST can output the data in any format (for example in CSV, JSON
or RSS).
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20154
REST Architecture
 Architectural style for distributed hypermedia systems, as Roy
Fielding originally described it in his doctoral dissertation in 2000
[8]
 Contains 6 main characteristics:
1. Uniform interface
 Resource based
 Manipulation of resources through representations
 Usage of self-descriptive messages
 Hypermedia as the engine of application state
2. Statelessness
3. Caching
4. Client-server separation
5. Layering
6. Code on demand
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20155
REST Architecture
 HTTP request semantics
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20156
Request Method Description
GET
Used for retrieving (or read) a representation of a
resource. If everything works, HTTP GET response
contains a representation in XML or JSON with
response code of 200 (OK).
POST
Most often used for creation of new resources. It is
actually used to create subordinate or child resource of
some other (parent) resource. When server receives
POST request, it creates new resource and assigns it a
new ID.
PUT
Used for update operations. Request body should
contain newly-updated representation of the original
resource which is identified by a known resource URI.
DELETE Used to delete URI-identified resource.
Android client implementation
• Example system
 Address Manager - enables users to get geographical location (latitude
and longitude) of any user defined address
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20157
Android client implementation
• Web service specification
 http://tinyurl.com/case27-locations
 x-www-form-urlencoded request
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20158
URL Method Params Response example
base GET - [{"id":1,"location":"Ivanec","lat":
"46.2228422","lon":"16.1246793"},
…]
base POST location {"id":1,"location":"Ivanec","lat":
"46.2228422","lon":"16.1246793"}
base/id PUT location {"id":1,"location":"Ivanec 2", "lat":
"47.2228422","lon":"15.1246793"}
Android client implementation
• Native Android web-service consumption
 web service communication layer
 response parsing layer
 manual threading
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20159
Android client implementation
• Native Android web-service consumption
 Repository – consists of set of methods that are leaning on web
services
 Service – represents web-service communication layer. This class
should be flexible to be able to execute any web service request.
 Callback – interface to be implemented by any callback object
containing logic for receiving web-service response.
 Parser – static class containing knowledge on parsing the responses.
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201510
Android client implementation
• Native
Repository
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201511
Android client implementation
• Retrofit implementation
 type-safe REST client for Android and Java
 turns your REST API into a Java interface
 upon downloading the data
is parsed into POJO which
must be defined for each
"resource" in the response
 flexible in message format
 uses compile-time annotation
processor
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201512
Android client implementation
• Retrofit implementation
 Define API interface
 Define RetrofitHelper that will instantiate adapter and interface
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201513
Android client implementation
• Retrofit implementation
 Call methods
 Handle response
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201514
Conclusion
• We presented
 REST application architectural style
 Two implementations of web-service communication layer
• Main contribution
 Architectural design for the two approaches
• Native vs Retrofit approach
 Native approach is robust and hard to adapt
 Retrofit is straightforward and flexible
• Source code
 http://tinyurl.com/case27-code
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201515
References
[1] D. Bosomworth, “Mobile marketing statistics 2015” Smart Insights, 2015. Available at:
http://www.smartinsights.com/mobile-marketing/mobile-marketing-analytics/mobile-marketingstatistics/ [Accessed: May-2015]
[2] ComScore Inc., “The U.S. Mobile App Report” 2014. Available at:
http://www.comscore.com/Insights/Presentations-and-Whitepapers/2014/The-US-Mobile-App-Report
[3] Statista, “Statistics and facts on Mobile Internet Usage,” Statista.com, 2015. [Online]. Available at:
http://www.statista.com/topics/779/mobile-internet/ [Accessed: May-2015].
[4] Android Developers, “Google Cloud Messaging for Android | Android Developers” Google Services,
2015. [Online]. Available at: https://developer.android.com/google/gcm/index.html [Accessed: May-2015].
[5] Apple inc., “Local and Push Notifications for Developers - Apple Developer” Developer Apple.com,
2015. [Online]. Available at: https://developer.apple.com/notifications/ [Accessed: May-2015].
[6] W3Schools.com, “Introduction to Web Services” Introduction to Web Services, 2015. [Online]. Available
at: http://www.w3schools.com/webservices/ws_intro.asp [Accessed: May-2015].
[7] W3Schools.com, “SOAP Introduction”, 2015. [Online]. Available at: http://www.w3schools.com/
webservices/ws_soap_intro.asp [Accessed: May-2015].
[8] R. T. Fielding, “Architectural Styles and the Design of Network-based Software Architectures”
UNIVERSITY OF CALIFORNIA, Irvine, 2000.
[9] A. Nene, “Web Services Architecture – When to Use SOAP vs REST” Javalobby, 2014. [Online]. Available
at: http://java.dzone.com/articles/web-services-architecture [Accessed: May-2015].
[10] J. Mueller, “Understanding SOAP and REST Basics” Software Quality Matters Blog, 2013. [Online].
Available at: http://blog.smartbear.com/apis/understanding-soap-and-rest-basics/ [Accessed: May-2015].
[11] F. Todd, “RESTful Service Best Practices, Recommendations for Creating Web Services”
RestAPITutorial.com, 2013.
[12] CodePath.com, “Consuming APIs with Retrofit” CodePath Android Cliffnotes, 2015. [Online]. Available
at: https://guides.codepath.com/android/Consuming-APIs-with-Retrofit#setup [Accessed: May-2015].
[13] StudyTrials, “Java Google Json (Gson) Introduction” StudyTrials.com. [Online]. Available at:
http://www.studytrails.com/java/json/java-google-json-introduction.jsp [Accessed: May-2015].
[14] “Google Gson” Google Gson Home, 2011. [Online]. Available at: https://sites.google.com/
site/gson/Home [Accessed: May-2015]
Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201516

More Related Content

What's hot

Gowsika_Cognos_Business_Intelligence
Gowsika_Cognos_Business_IntelligenceGowsika_Cognos_Business_Intelligence
Gowsika_Cognos_Business_IntelligenceGowsika Kamaraj
 
Beauty rani2.5 yrs exp in manual and selenium bangalore
Beauty rani2.5 yrs exp in manual and selenium bangaloreBeauty rani2.5 yrs exp in manual and selenium bangalore
Beauty rani2.5 yrs exp in manual and selenium bangalore
Beauty Rani
 
ABHIJIT_SEN_PERFORMANCE_TESTING
ABHIJIT_SEN_PERFORMANCE_TESTINGABHIJIT_SEN_PERFORMANCE_TESTING
ABHIJIT_SEN_PERFORMANCE_TESTINGAbhijit Sen
 
MuleSoft Meetup Bangalore #12
MuleSoft Meetup Bangalore #12MuleSoft Meetup Bangalore #12
MuleSoft Meetup Bangalore #12
Nagaraju K R
 
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
WSO2
 
API Best Practices Webinar: Metrics - What to Measure
API Best Practices Webinar:  Metrics - What to MeasureAPI Best Practices Webinar:  Metrics - What to Measure
API Best Practices Webinar: Metrics - What to Measure
Apigee | Google Cloud
 
Rahul_Gaur_Resume
Rahul_Gaur_ResumeRahul_Gaur_Resume
Rahul_Gaur_ResumeRahul Gaur
 
Mule soft meetup____indy_may_02
Mule soft meetup____indy_may_02Mule soft meetup____indy_may_02
Mule soft meetup____indy_may_02
Amit Bhusan Srivastava
 
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 159 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
Open API Initiative (OAI)
 
Effective API Lifecycle Management
Effective API Lifecycle Management Effective API Lifecycle Management
Effective API Lifecycle Management
SmartBear
 
Benefits of AngularJS Development for Your Business - APPNWEB Technologies
Benefits of AngularJS Development for Your Business - APPNWEB TechnologiesBenefits of AngularJS Development for Your Business - APPNWEB Technologies
Benefits of AngularJS Development for Your Business - APPNWEB Technologies
APPNWEB Technologies
 
Renuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi
 
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
apidays
 
Resume
ResumeResume
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relicapidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
apidays
 
Feature Scoring in Green Field Application Development and DevOps
Feature Scoring in Green Field Application Development and DevOpsFeature Scoring in Green Field Application Development and DevOps
Feature Scoring in Green Field Application Development and DevOps
DevOps Indonesia
 
Srinivas_Selenium_3 Years_Resume
Srinivas_Selenium_3 Years_ResumeSrinivas_Selenium_3 Years_Resume
Srinivas_Selenium_3 Years_ResumeSrinivasa rao
 

What's hot (20)

Gowsika_Cognos_Business_Intelligence
Gowsika_Cognos_Business_IntelligenceGowsika_Cognos_Business_Intelligence
Gowsika_Cognos_Business_Intelligence
 
Beauty rani2.5 yrs exp in manual and selenium bangalore
Beauty rani2.5 yrs exp in manual and selenium bangaloreBeauty rani2.5 yrs exp in manual and selenium bangalore
Beauty rani2.5 yrs exp in manual and selenium bangalore
 
ABHIJIT_SEN_PERFORMANCE_TESTING
ABHIJIT_SEN_PERFORMANCE_TESTINGABHIJIT_SEN_PERFORMANCE_TESTING
ABHIJIT_SEN_PERFORMANCE_TESTING
 
MuleSoft Meetup Bangalore #12
MuleSoft Meetup Bangalore #12MuleSoft Meetup Bangalore #12
MuleSoft Meetup Bangalore #12
 
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
Trouble with Performance Debugging? Not Anymore with Choreo, the AI-Assisted ...
 
vishal kaneria
vishal kaneriavishal kaneria
vishal kaneria
 
API Best Practices Webinar: Metrics - What to Measure
API Best Practices Webinar:  Metrics - What to MeasureAPI Best Practices Webinar:  Metrics - What to Measure
API Best Practices Webinar: Metrics - What to Measure
 
Rahul_Gaur_Resume
Rahul_Gaur_ResumeRahul_Gaur_Resume
Rahul_Gaur_Resume
 
Mule soft meetup____indy_may_02
Mule soft meetup____indy_may_02Mule soft meetup____indy_may_02
Mule soft meetup____indy_may_02
 
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 159 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
9 Months and Counting with Jeff Borek of IBM OpenAPI Meetup 2016 09 15
 
Effective API Lifecycle Management
Effective API Lifecycle Management Effective API Lifecycle Management
Effective API Lifecycle Management
 
Benefits of AngularJS Development for Your Business - APPNWEB Technologies
Benefits of AngularJS Development for Your Business - APPNWEB TechnologiesBenefits of AngularJS Development for Your Business - APPNWEB Technologies
Benefits of AngularJS Development for Your Business - APPNWEB Technologies
 
Renuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr Exp
 
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
apidays LIVE Australia 2020 - Growing an API Culture by Liz Douglass & Saul C...
 
Resume
ResumeResume
Resume
 
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relicapidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
apidays LIVE Hong Kong 2021 - DevOps is Dead by Jason Esli, New Relic
 
Feature Scoring in Green Field Application Development and DevOps
Feature Scoring in Green Field Application Development and DevOpsFeature Scoring in Green Field Application Development and DevOps
Feature Scoring in Green Field Application Development and DevOps
 
ShainaResume
ShainaResumeShainaResume
ShainaResume
 
Srinivas_Selenium_3 Years_Resume
Srinivas_Selenium_3 Years_ResumeSrinivas_Selenium_3 Years_Resume
Srinivas_Selenium_3 Years_Resume
 
UpwanGupta
UpwanGuptaUpwanGupta
UpwanGupta
 

Viewers also liked

Retrofit
RetrofitRetrofit
Retrofit
Amin Cheloh
 
Retrofit
RetrofitRetrofit
Retrofit
bresiu
 
Android libs by Square - make your development a bit easier
Android libs by Square - make your development a bit easierAndroid libs by Square - make your development a bit easier
Android libs by Square - make your development a bit easier
Sylwester Madej
 
Android and REST
Android and RESTAndroid and REST
Android and REST
Roman Woźniak
 
Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...
Zlatko Stapic
 
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris Ollenburg
Trey Robinson
 
Android-Tp5 : web services
Android-Tp5 : web servicesAndroid-Tp5 : web services
Android-Tp5 : web services
Lilia Sfaxi
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
Daniel Costa Gimenes
 

Viewers also liked (8)

Retrofit
RetrofitRetrofit
Retrofit
 
Retrofit
RetrofitRetrofit
Retrofit
 
Android libs by Square - make your development a bit easier
Android libs by Square - make your development a bit easierAndroid libs by Square - make your development a bit easier
Android libs by Square - make your development a bit easier
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...
 
Retrofit Android by Chris Ollenburg
Retrofit Android by Chris OllenburgRetrofit Android by Chris Ollenburg
Retrofit Android by Chris Ollenburg
 
Android-Tp5 : web services
Android-Tp5 : web servicesAndroid-Tp5 : web services
Android-Tp5 : web services
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
 

Similar to Using Retrofit framework in implementation of Android REST client (Presentation)

Automatized Application Services for Android Devices Using Apache Ant in Clou...
Automatized Application Services for Android Devices Using Apache Ant in Clou...Automatized Application Services for Android Devices Using Apache Ant in Clou...
Automatized Application Services for Android Devices Using Apache Ant in Clou...
IRJET Journal
 
Prakash Singh Resume.docx
Prakash Singh Resume.docxPrakash Singh Resume.docx
Prakash Singh Resume.docx
prakashSingh712632
 
Resume (2).docx
Resume (2).docxResume (2).docx
Resume (2).docx
RoshanChaubey
 
Oracle mobile cloud service
Oracle mobile cloud serviceOracle mobile cloud service
Oracle mobile cloud service
shravan kumar chelika
 
Afzal-Khan-Resume
Afzal-Khan-ResumeAfzal-Khan-Resume
Afzal-Khan-Resumeafzal khan
 
IoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdfIoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdf
GVNSK Sravya
 
Rajat Kanti Gupta
Rajat Kanti GuptaRajat Kanti Gupta
Rajat Kanti GuptaRajat Gupta
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
Web engineering cse ru
Web engineering cse ruWeb engineering cse ru
Web engineering cse ru
Hossain Md Shakhawat
 
Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016Subhajit Das
 
Mridul_Mandal_Resume_5+yrs_QA
Mridul_Mandal_Resume_5+yrs_QAMridul_Mandal_Resume_5+yrs_QA
Mridul_Mandal_Resume_5+yrs_QAMridul Mandal
 
Updated resume
Updated resumeUpdated resume
Updated resume
Arun Kiran
 
Disruptive Trends in Application Development
Disruptive Trends in Application DevelopmentDisruptive Trends in Application Development
Disruptive Trends in Application Development
WaveMaker, Inc.
 

Similar to Using Retrofit framework in implementation of Android REST client (Presentation) (20)

Automatized Application Services for Android Devices Using Apache Ant in Clou...
Automatized Application Services for Android Devices Using Apache Ant in Clou...Automatized Application Services for Android Devices Using Apache Ant in Clou...
Automatized Application Services for Android Devices Using Apache Ant in Clou...
 
Prakash Singh Resume.docx
Prakash Singh Resume.docxPrakash Singh Resume.docx
Prakash Singh Resume.docx
 
GauthamRaj_SI_Resume
GauthamRaj_SI_ResumeGauthamRaj_SI_Resume
GauthamRaj_SI_Resume
 
PRASANTHI P
PRASANTHI PPRASANTHI P
PRASANTHI P
 
Shilpanjali_Resume
Shilpanjali_ResumeShilpanjali_Resume
Shilpanjali_Resume
 
Resume (2).docx
Resume (2).docxResume (2).docx
Resume (2).docx
 
SreenuPrasad
SreenuPrasadSreenuPrasad
SreenuPrasad
 
Oracle mobile cloud service
Oracle mobile cloud serviceOracle mobile cloud service
Oracle mobile cloud service
 
Afzal-Khan-Resume
Afzal-Khan-ResumeAfzal-Khan-Resume
Afzal-Khan-Resume
 
IoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdfIoT Physical Servers and Cloud Offerings.pdf
IoT Physical Servers and Cloud Offerings.pdf
 
Rajat Kanti Gupta
Rajat Kanti GuptaRajat Kanti Gupta
Rajat Kanti Gupta
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
Raju_Resume
Raju_ResumeRaju_Resume
Raju_Resume
 
Web engineering cse ru
Web engineering cse ruWeb engineering cse ru
Web engineering cse ru
 
Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016Subhajit_Das_Resume_(M)2016
Subhajit_Das_Resume_(M)2016
 
Mridul_Mandal_Resume_5+yrs_QA
Mridul_Mandal_Resume_5+yrs_QAMridul_Mandal_Resume_5+yrs_QA
Mridul_Mandal_Resume_5+yrs_QA
 
RohiniKrishna_Feb
RohiniKrishna_FebRohiniKrishna_Feb
RohiniKrishna_Feb
 
Updated resume
Updated resumeUpdated resume
Updated resume
 
Disruptive Trends in Application Development
Disruptive Trends in Application DevelopmentDisruptive Trends in Application Development
Disruptive Trends in Application Development
 

More from Zlatko Stapic

Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...
Zlatko Stapic
 
Comparing native Android and jQuery Mobile capabilities
Comparing native Android and jQuery Mobile capabilitiesComparing native Android and jQuery Mobile capabilities
Comparing native Android and jQuery Mobile capabilities
Zlatko Stapic
 
Comparing native Android and jQuery Mobile capabilities (Presentation)
Comparing native Android and jQuery Mobile capabilities (Presentation)Comparing native Android and jQuery Mobile capabilities (Presentation)
Comparing native Android and jQuery Mobile capabilities (Presentation)
Zlatko Stapic
 
Challenges in development of RPG mobile application
Challenges in development of RPG mobile applicationChallenges in development of RPG mobile application
Challenges in development of RPG mobile applicationZlatko Stapic
 
Challenges in development of RPG mobile application (Presentation)
Challenges in development of RPG mobile application (Presentation)Challenges in development of RPG mobile application (Presentation)
Challenges in development of RPG mobile application (Presentation)
Zlatko Stapic
 
Monetizing mobile applications
Monetizing mobile applicationsMonetizing mobile applications
Monetizing mobile applications
Zlatko Stapic
 
Monetizing mobile applications (Presentation)
Monetizing mobile applications (Presentation)Monetizing mobile applications (Presentation)
Monetizing mobile applications (Presentation)
Zlatko Stapic
 

More from Zlatko Stapic (7)

Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...Using Mobile-D methodology in development of mobile applications: Challenges ...
Using Mobile-D methodology in development of mobile applications: Challenges ...
 
Comparing native Android and jQuery Mobile capabilities
Comparing native Android and jQuery Mobile capabilitiesComparing native Android and jQuery Mobile capabilities
Comparing native Android and jQuery Mobile capabilities
 
Comparing native Android and jQuery Mobile capabilities (Presentation)
Comparing native Android and jQuery Mobile capabilities (Presentation)Comparing native Android and jQuery Mobile capabilities (Presentation)
Comparing native Android and jQuery Mobile capabilities (Presentation)
 
Challenges in development of RPG mobile application
Challenges in development of RPG mobile applicationChallenges in development of RPG mobile application
Challenges in development of RPG mobile application
 
Challenges in development of RPG mobile application (Presentation)
Challenges in development of RPG mobile application (Presentation)Challenges in development of RPG mobile application (Presentation)
Challenges in development of RPG mobile application (Presentation)
 
Monetizing mobile applications
Monetizing mobile applicationsMonetizing mobile applications
Monetizing mobile applications
 
Monetizing mobile applications (Presentation)
Monetizing mobile applications (Presentation)Monetizing mobile applications (Presentation)
Monetizing mobile applications (Presentation)
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 

Using Retrofit framework in implementation of Android REST client (Presentation)

  • 1. Using Retrofit framework in implementation of Android REST client David Ante Macan*, Zlatko Stapić, Milan Pavlović* University of Zagreb Faculty of Organization and Informatics Pavlinska 2, 42000 Varaždin, Croatia http://www.foi.unizg.hr/ CASE27 – Developers conference - 02.06.2015. – Zagreb, Croatia * Students at University of Zagreb, FOI Varazdin
  • 2. Agenda • Introduction • REST Architecture • Android client implementation • Implementation using Retrofit • Conclusion • References Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20152
  • 3. Introduction • Today’s mobile applications are Internet dependent • 2017 -> 90% [1], [3] • Web services are used for supporting mobile application functionalities  Internet dependent monetization models  App usage statistics, data synchronization, social components, score tables… • Backend servers for push notifications • Web service – self contained and self describing application component that can be used by other applications and can be communicated by using open protocols [6] Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20153
  • 4. Introduction • After SOA became widely used for mobile and other applications, the dominant way of exchanging the data with web services was by using SOAP [7] • XML used for creating requests and responses was too complex and requests had to be build manually -> problematic due to protocols intolerance on any errors • REST (Representational State Transfer) provides lightweight alternative and relies on simple URL approach • REST can output the data in any format (for example in CSV, JSON or RSS). Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20154
  • 5. REST Architecture  Architectural style for distributed hypermedia systems, as Roy Fielding originally described it in his doctoral dissertation in 2000 [8]  Contains 6 main characteristics: 1. Uniform interface  Resource based  Manipulation of resources through representations  Usage of self-descriptive messages  Hypermedia as the engine of application state 2. Statelessness 3. Caching 4. Client-server separation 5. Layering 6. Code on demand Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20155
  • 6. REST Architecture  HTTP request semantics Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20156 Request Method Description GET Used for retrieving (or read) a representation of a resource. If everything works, HTTP GET response contains a representation in XML or JSON with response code of 200 (OK). POST Most often used for creation of new resources. It is actually used to create subordinate or child resource of some other (parent) resource. When server receives POST request, it creates new resource and assigns it a new ID. PUT Used for update operations. Request body should contain newly-updated representation of the original resource which is identified by a known resource URI. DELETE Used to delete URI-identified resource.
  • 7. Android client implementation • Example system  Address Manager - enables users to get geographical location (latitude and longitude) of any user defined address Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20157
  • 8. Android client implementation • Web service specification  http://tinyurl.com/case27-locations  x-www-form-urlencoded request Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20158 URL Method Params Response example base GET - [{"id":1,"location":"Ivanec","lat": "46.2228422","lon":"16.1246793"}, …] base POST location {"id":1,"location":"Ivanec","lat": "46.2228422","lon":"16.1246793"} base/id PUT location {"id":1,"location":"Ivanec 2", "lat": "47.2228422","lon":"15.1246793"}
  • 9. Android client implementation • Native Android web-service consumption  web service communication layer  response parsing layer  manual threading Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 20159
  • 10. Android client implementation • Native Android web-service consumption  Repository – consists of set of methods that are leaning on web services  Service – represents web-service communication layer. This class should be flexible to be able to execute any web service request.  Callback – interface to be implemented by any callback object containing logic for receiving web-service response.  Parser – static class containing knowledge on parsing the responses. Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201510
  • 11. Android client implementation • Native Repository Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201511
  • 12. Android client implementation • Retrofit implementation  type-safe REST client for Android and Java  turns your REST API into a Java interface  upon downloading the data is parsed into POJO which must be defined for each "resource" in the response  flexible in message format  uses compile-time annotation processor Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201512
  • 13. Android client implementation • Retrofit implementation  Define API interface  Define RetrofitHelper that will instantiate adapter and interface Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201513
  • 14. Android client implementation • Retrofit implementation  Call methods  Handle response Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201514
  • 15. Conclusion • We presented  REST application architectural style  Two implementations of web-service communication layer • Main contribution  Architectural design for the two approaches • Native vs Retrofit approach  Native approach is robust and hard to adapt  Retrofit is straightforward and flexible • Source code  http://tinyurl.com/case27-code Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201515
  • 16. References [1] D. Bosomworth, “Mobile marketing statistics 2015” Smart Insights, 2015. Available at: http://www.smartinsights.com/mobile-marketing/mobile-marketing-analytics/mobile-marketingstatistics/ [Accessed: May-2015] [2] ComScore Inc., “The U.S. Mobile App Report” 2014. Available at: http://www.comscore.com/Insights/Presentations-and-Whitepapers/2014/The-US-Mobile-App-Report [3] Statista, “Statistics and facts on Mobile Internet Usage,” Statista.com, 2015. [Online]. Available at: http://www.statista.com/topics/779/mobile-internet/ [Accessed: May-2015]. [4] Android Developers, “Google Cloud Messaging for Android | Android Developers” Google Services, 2015. [Online]. Available at: https://developer.android.com/google/gcm/index.html [Accessed: May-2015]. [5] Apple inc., “Local and Push Notifications for Developers - Apple Developer” Developer Apple.com, 2015. [Online]. Available at: https://developer.apple.com/notifications/ [Accessed: May-2015]. [6] W3Schools.com, “Introduction to Web Services” Introduction to Web Services, 2015. [Online]. Available at: http://www.w3schools.com/webservices/ws_intro.asp [Accessed: May-2015]. [7] W3Schools.com, “SOAP Introduction”, 2015. [Online]. Available at: http://www.w3schools.com/ webservices/ws_soap_intro.asp [Accessed: May-2015]. [8] R. T. Fielding, “Architectural Styles and the Design of Network-based Software Architectures” UNIVERSITY OF CALIFORNIA, Irvine, 2000. [9] A. Nene, “Web Services Architecture – When to Use SOAP vs REST” Javalobby, 2014. [Online]. Available at: http://java.dzone.com/articles/web-services-architecture [Accessed: May-2015]. [10] J. Mueller, “Understanding SOAP and REST Basics” Software Quality Matters Blog, 2013. [Online]. Available at: http://blog.smartbear.com/apis/understanding-soap-and-rest-basics/ [Accessed: May-2015]. [11] F. Todd, “RESTful Service Best Practices, Recommendations for Creating Web Services” RestAPITutorial.com, 2013. [12] CodePath.com, “Consuming APIs with Retrofit” CodePath Android Cliffnotes, 2015. [Online]. Available at: https://guides.codepath.com/android/Consuming-APIs-with-Retrofit#setup [Accessed: May-2015]. [13] StudyTrials, “Java Google Json (Gson) Introduction” StudyTrials.com. [Online]. Available at: http://www.studytrails.com/java/json/java-google-json-introduction.jsp [Accessed: May-2015]. [14] “Google Gson” Google Gson Home, 2011. [Online]. Available at: https://sites.google.com/ site/gson/Home [Accessed: May-2015] Macan, Stapić, Pavlović: Using Retrofit framework in implementation of Android REST client - CASE27, 2nd June 201516