Android(Kotlin)
Retrofit - Send a simple GET Request | Android Studio Tutorial
----___<<<<<
2022. 2. 2. 19:33
아래 영상의 예제입니다.
https://www.youtube.com/watch?v=sBCE_hOFnQU&list=PLSrm9z4zp4mF1Ssdfuocy2XH5Bw4wLLNw
우선 폴더 구조는 아래와 같습니다.
Internet permission을 연결하고
<uses-permission android:name="android.permission.INTERNET"/>
Gradle에 아래와 같이 추가합니다.
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0")
아래와 같이 코드를 작성합니다.