Loading
Please wait, content is loading
Logo Black Logo White
  • Portfolio
  • About
  • Stories
  • Contact
Menu

Recent Posts

  • Android – API Interceptor
  • Retrofit Logging Interceptor

Recent Comments

No comments to show.
Recent Posts
  • Android – API Interceptor
  • Retrofit Logging Interceptor
Recent Comments
No comments to show.
  • February 26, 2025

Retrofit Logging Interceptor

  • Android
  • Kotlin
  • Retrofit
Post Image

Using Logging Interceptor, all the network flow can easily be observed using Logcat and also set connect timeout, read timeout and write timeout manually.

These are set inside RetrofitInstance.kt class.

val intercepter = HttpLoggingInterceptor().apply {
    this.level = HttpLoggingInterceptor.Level.BODY
}
val client = OkHttpClient.Builder().apply {
    this.addInterceptor(intercepter)
}.build()

These are for Network flow tracking. if we need a manual time setting?

val intercepter = HttpLoggingInterceptor().apply {
    this.level = HttpLoggingInterceptor.Level.BODY
}
val client = OkHttpClient.Builder().apply {
    this.addInterceptor(intercepter) // time out setting
        .connectTimeout(3, TimeUnit.SECONDS)
        .readTimeout(20, TimeUnit.SECONDS)
        .writeTimeout(25, TimeUnit.SECONDS)

}.build()
Files

RetrofitInstanceDownload

Prev
Android – API Interceptor
Next
No more posts
  • No Comments
  • Leave a comment
Cancel Reply

Back Top
2025 © VGraphics IKE. All rights reserved.

Gemi 181823306000 • George Vergidis (100%/500€)

Follow Us
  • Ld