Retrofit - Send a simple GET Request | Android Studio Tutorial

preview_player
Показать описание
🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN

🐱‍👤 Wanna become a member? Join!

📸 Instagram

Retrofit is a Type Safe REST client for Android Developed by square. It uses okHttp library for HTTP requests, and it's one of the best tools for performing network requests in android applications. In this video I'll show you how to send a simple GET request, receive a result in JSON, convert it to Kotlin object and display it back in our app. So with this video I'm starting a new short tutorial series about Retrofit library, so stay tuned!

Retrofit requires three main components:
1. Retrofit Instance:
We can create an instance of Retrofit by Retrofit.Builder class. And we have to specify the base url and converter factory at the time of the Retrofit instance creation

2. Model Class:
Retrofit needs a Model class for sending and receiving Request. It uses the model class for parsing server Response by using converters like Gson, Moshi etc.

3. An Interface for possible API calls:
The interface contains methods that represents possible API calls. Each methods need a base Url end point annotation that represents the Http methods like GET, POST etc.

Timestamps:
0:00 - Introduction
1:12 - Create Model class
2:28 - Create SimpleApi interface
3:15 - Create Constants class
3:53 - Create RetrofitInstance object (Singleton)
5:02 - Create Repository
5:43 - Create MainViewModel class
6:46 - Create MainViewModelFactory class
7:25 - Implement the logic
9:29 - Handle Exceptions
Рекомендации по теме
Комментарии
Автор

This video is GOLD. Came only for Retrofit, left with much more.

sebbytrial
Автор

Finally, an API call example that is easy to follow and is structured in the proper way. Thank you.

irohwavez
Автор

man...seriously... your content is amazing :| exactly on point, so simple explained.. so clean :) thank you! we really appreciate your work

kalibra
Автор

Its 2023 and this tutorial is still serving well❤

solomonayodeleo
Автор

Your Tutorials are great....keep up the great work...love you

mrandroid
Автор

you make android intern's life easy and smooth, thank you again

pradeep
Автор

Amazing tutorial as always! 😊 I like your channel.

FarrukhSaliev
Автор

Well done! the only thing I want to suggest is to use another name for the model you are using: Post is easy to confuse with Http/Post.
the rest is great!

AndreaDeGaetanoDotCom
Автор

Your channel and awesome videos made me start developing Android apps, thank you!

fb
Автор

Great tutorial, THANKS, looking forward to see the next tutorial/s

Waleed_Al-Haidary
Автор

Really helpful video. Really like the way you structure things

GameWorkflow
Автор

This was incredibly useful. Thank you.

emanuelalvarez
Автор

Awesome tutorial. Thanks for this tutorial.
Waiting for next one.

pushpendratripathi
Автор

Great 👌, I have a question about to how use GET to search published articles in your personal website that u loaded in a webview using searchview

alexsibiya
Автор

Thanks. It was a really understandable training video!

dimensions-xyz
Автор

i have an URL with xml content on it. I want to GET the xml data every time I start my activity. Then I want to present certain parts of the data in my app. How should I go about this?

gunther
Автор

Ciao Stvdza, thanks a lot for the video! How should I handle a SocketTimeoutException error (the App keeps crushing in that case)?

AlessandroMariucciConsulting
Автор

thanks for the video, helped a lot man

andreaf
Автор

The way you provide the dependencies through a pattern is it called MVC or MVP ?

cmyxxdf
Автор

Your videos are very good and very useful. I would love for you to show examples of delete and update with retrofit, it would be very helpful. Thank you so much

federicomoreiratejera