Android Retrofit Interceptors + OkHttpClient | CheezyCode (Hindi)

  Рет қаралды 17,526

Cheezy Code

Cheezy Code

2 жыл бұрын

Android Tutorial For Beginners - Learn how to use interceptors for passing dynamic header values with every request. Retrofit uses OkHttp behind the scenes. We need to create OkHttpClient to add interceptors. These interceptors help in adding headers to every request or you can add logging for every request using these interceptors. Interceptor is a powerful way to add dynamic values to your request object. Learn how to implement AuthInterceptor and OkHttpClient in this video.
Learn how to implement Retrofit object with OkHttpClient along with HILT. This video clearly explains how to define Network Module for HILT. How to define different functions inside your module to provide you both Authenticated and UnAuthenticated flow. Learn step by step - how to create a fully functional android app with simple example in Hindi.
Topics covered -
1. What is Interceptor in Retrofit?
2. How to implement Interceptor for Authentication Headers?
3. How to pass tokens in every request in retrofit android.
4. Create OkHttpClient and use it to create Retrofit Object
5. Implement all this using HILT
6. Complete Notes Android App Tutorial Hindi
Complete Dependency Injection Playlist Link -
• Dagger 2 - Dependency ...
Complete Android Architecture Components Playlist -
• Android Architecture C...
Beginner series in Android Playlist (Hindi) -
• Android Tutorials Step...
Kotlin Beginners Tutorial Series -
• Kotlin Beginner Tutori...
For more info - visit the below link
www.cheezycode.com
Source Code -
github.com/CheezyCode/YetAnot...
We are social. Follow us at -
Facebook - / cheezycode
Twitter - / cheezycode
Instagram - / cheezycode

Пікірлер: 54
@vikasrana1584
@vikasrana1584 Жыл бұрын
your explanation is amazing, Easy to understand . And Learn from your videos audience should have basic android development knowledge @cheexy code . Your channel as like a fast learning platform, over all thing done well.
@nayannit
@nayannit 2 жыл бұрын
Today I was searching for the Retrofit interceptors on KZfaq especially for your channel, and what a coincidence, just got the notification 😅..
@CheezyCode
@CheezyCode 2 жыл бұрын
😊
@user-nx6tn1sm3i
@user-nx6tn1sm3i 4 ай бұрын
us bro us 😍
@sunilmane2994
@sunilmane2994 Жыл бұрын
Thank you Sir, Making this awasome video..You are great man ❤️❤️
@CheezyCode
@CheezyCode Жыл бұрын
Thanks and welcome
@nitinbochare301
@nitinbochare301 2 жыл бұрын
Awesome sir easy to understand waiting for next video😊
@CheezyCode
@CheezyCode 2 жыл бұрын
Thank you Nitin
@anitavaghasiya369
@anitavaghasiya369 Жыл бұрын
sir, your explanation is very good,keep it and make more and more videos on kotlin.Thank you sir
@CheezyCode
@CheezyCode Жыл бұрын
Thank you, I will
@chunilalgamit5369
@chunilalgamit5369 Жыл бұрын
Great tutorial Sir, Please add one video related to auto refresh token when expired and continue with requested API call.
@kushal7966
@kushal7966 2 жыл бұрын
Thank you sir.
@CheezyCode
@CheezyCode 2 жыл бұрын
Thank you to you too...
@TheAqib57
@TheAqib57 2 жыл бұрын
shukriya bhai
@CheezyCode
@CheezyCode 2 жыл бұрын
Thank you Uno
@mdjafarhamadhamad6509
@mdjafarhamadhamad6509 2 жыл бұрын
amajing advice
@CheezyCode
@CheezyCode 2 жыл бұрын
Thanks
@yonija007
@yonija007 7 ай бұрын
Great explanation. Can you please create a video or explain how we can navigate user to Login screen upon token expired/invalid.
@pramodkumar-zc8et
@pramodkumar-zc8et 2 жыл бұрын
Very nice explanation. Please make a video on Leak Canary.
@CheezyCode
@CheezyCode 2 жыл бұрын
Sure I will
@AkashJhaDDN
@AkashJhaDDN 2 жыл бұрын
Thanks
@CheezyCode
@CheezyCode 2 жыл бұрын
Welcome
@bhavyashah7052
@bhavyashah7052 2 жыл бұрын
In our android team we have 50+ developers who work in large projects of kotlin and use your videos as reference plz cover with all maximum details as soon as possible
@CheezyCode
@CheezyCode 2 жыл бұрын
Sabse subscribe bhi karwa do 😂
@bhavyashah7052
@bhavyashah7052 2 жыл бұрын
Sure sabko laptop and mobile dono se subscribe karva lunga 😂😂
@mandeepbhalothia7626
@mandeepbhalothia7626 2 жыл бұрын
Great explained! Can you please explain how to pass dynamic BASE urls using hilt, in this video BaseUrl is static?
@CheezyCode
@CheezyCode 2 жыл бұрын
Thanks 👍...we will create a separate tutorial for that...you can write a logic to separate these via build config...for dev you can use different url and for prod different url...
@mrdeveloper4438
@mrdeveloper4438 2 жыл бұрын
Nice explane..but why not use base fragment...every time you need override the oncreate method that is not required..
@CheezyCode
@CheezyCode 2 жыл бұрын
Yes... already bahot badi series hogayi hai...we can certainly define one base fragment and have common methods inside it
@daxaparmar373
@daxaparmar373 Жыл бұрын
Hi, I'm working on a project which has 100+ api calls and I'm using retrofit...so in my retrofit interface I want to define generic methods for @POST, @GET, @PUT methods. Im providing endpoint dynamically and request as "Any" type and return type as "Response". But Retrofit doesn't parse body to dynamic type T. So, How can I use generic with retrofit interface?
@CheezyCode
@CheezyCode Жыл бұрын
Refer this solution - stackoverflow.com/a/43935291 Another solution could be having a wrapper api that internally calls your endpoint on server. You will just the call one method with all the data
@ProjectAryawarta
@ProjectAryawarta Жыл бұрын
This code works over http not over https, how to automatically trust the host and certificate?
@Adnankhan-dq9rx
@Adnankhan-dq9rx Жыл бұрын
That interceptor will automatically refresh token after it will expire . or we have to hit server again to refresh token ???
@CheezyCode
@CheezyCode Жыл бұрын
We have to manage...
@androidsurfers7572
@androidsurfers7572 2 жыл бұрын
hii sir very nice explanations but what if we have more than one haeders like Content-type - application/json
@CheezyCode
@CheezyCode 2 жыл бұрын
Add it via interceptor only
@rishikeshsingh9946
@rishikeshsingh9946 2 жыл бұрын
#awesome sir...
@CheezyCode
@CheezyCode 2 жыл бұрын
❤️
@samridhikotnala4958
@samridhikotnala4958 Жыл бұрын
Sir for login I need to pass a tenant type and then after that I have my normal APIs that require Autorization header. So should I pass both of them in a single interceptor or different interceptors are needed?
@CheezyCode
@CheezyCode Жыл бұрын
2 calls hai ye 1 call mei 2 info bhejni h? if 2 calls hai then you can add it directly in your first api call and then use this interceptor in second call for authorization. Tenant type will be required only once I guess. No need to create interceptor for that.
@samridhikotnala4958
@samridhikotnala4958 Жыл бұрын
@Cheezy Code Yes sir 2 calls hai. Ok sir I will try to implement it. Thank you so much for this playlist and replying to each and every comment on every video on time! 🙇🏻‍♀️
@Sound_Of_Arpit
@Sound_Of_Arpit 2 жыл бұрын
Sir How many videos are remaining in this series?
@CheezyCode
@CheezyCode 2 жыл бұрын
2 will be sufficient but let's see
@codetheandroid
@codetheandroid Жыл бұрын
12:35 bro is point pe aapne jo chij kri h same chij maine kri ek response test krne ke liye pr meri app phle crash hori h aur error deri h : E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1 aur bro ek doubt tha maine kuch machine learning model ki api build kri thi azure cognitive service ka use krke to usne mujhe bnane ke baad ek url diya prediction ka aur kuch bhi nhi diye na end points vgera to ab m agr api interpace me only '/' likh ra hu to bhi error ari h . pr agr same url endpoint me derha hu to app ek bar crash kr ri h aur upr vali error deri h aur fir dubar run krra hu to reponse return kr ri h pr phir kbhi app dubara open kru to fir se error
@CheezyCode
@CheezyCode Жыл бұрын
1. Use try catch - kuch error aa rahi h api hit karne pe 2. @Url annotation ka use karo - full url pass karna padega iss case. E.g. @GET suspend fun methodName(@Url String url);
@codetheandroid
@codetheandroid Жыл бұрын
@@CheezyCode phir full url @url annotation me pass kru to same full url retrofit ke base url me dalna pdega
@CheezyCode
@CheezyCode Жыл бұрын
Base url won't be used in this case.. check the scrapping video
@DahabJr
@DahabJr Жыл бұрын
Where is the English version?!
@tanveerahmed729
@tanveerahmed729 2 жыл бұрын
If anyone want to learn latest Android code watch vlog of cheeze code.
@CheezyCode
@CheezyCode 2 жыл бұрын
Tutorial ❤️
@tanveerahmed729
@tanveerahmed729 2 жыл бұрын
@@CheezyCode ok sir.
@Now_I_am_all_fired_up
@Now_I_am_all_fired_up 2 жыл бұрын
Is it true ... I can earn 1 lakh rs/month from freelancing websites by doing android .. 🤔
@CheezyCode
@CheezyCode 2 жыл бұрын
True but requires hardwork...easy nahi h freelancing se kaam uthana
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 12 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4,5 МЛН
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 99 МЛН
How to use the OkHttp library in Android Studio
13:03
Codes Easy
Рет қаралды 19 М.
Retrofit in Android Studio using Kotlin | Android Knowledge
19:05
Android Knowledge
Рет қаралды 4,9 М.
Retrofit Caching Example and Why it SUCKS
22:56
CodingWithMitch
Рет қаралды 16 М.
Fragment Lifecycle in Android - Android Studio Tutorial
15:55
Neat Roots
Рет қаралды 8 М.
Shrink, Optimize and Secure Your App With R8 & ProGuard - Full Guide
18:08
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 12 МЛН