From the course: Android Development Essential Training: Manage Data with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Define a Retrofit interface

Define a Retrofit interface

From the course: Android Development Essential Training: Manage Data with Kotlin

Start my 1-month free trial

Define a Retrofit interface

- [Instructor] After adding dependencies for Retrofit and coroutines, you're ready to create what's called a Retrofit interface. Each interface represents a call to a web service. I'm going to be working with a web service at this URL, at 774906.youcanlearnit.net. Notice I'm using https for encrypted traffic. There are two important directories here. The feed directory contains a copy of my data file, monster_data.json. It's exactly the same file that was packaged in the project. And the images directory contains webp files. For each data item, there's a webp image that's full-size and a thumbnail version that has the suffix _tn. I'll go to my Global.kt file, and I'm going to declare a constant that is the location of the web service. So that will be const val. I'll call this WEB_SERVICE_URL. I'll put in a pair of double quotes. I'll come back to my browser, and I'll select just the route directory. I'll copy it and paste it in. Now that's available to the entire application. Next…

Contents