네트워크 라이브러리
_ Retrofit2 라이브러리 사용을 위한 설정
1. 오픈 소스 라이브러리를 다운로드한다.
- retrofit2
: 네트워크 통신용 라이브러리
- converter-gson
: json을 바로 클래스로 만들어 주는 라이브러리
- logging-interceptor
: 네트워크를 어떻게 주고 어떻게 받았는지 확인할 수 있는 개발자용 라이브러리이다.
- build.gradle.kts (Module)에 설치하기
dependencies {
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation("com.github.bumptech.glide:glide:4.16.0")
}
2. 네트워크 권한 설정하기
- app/manifests/AndroidManifest.xml 파일에 작성
<uses-permission android:name="android.permission.INTERNET"/>
3. retrofit2 사용 준비 완료!
* retrofit 오픈 소스 라이브러리
https://github.com/square/retrofit
GitHub - square/retrofit: A type-safe HTTP client for Android and the JVM
A type-safe HTTP client for Android and the JVM. Contribute to square/retrofit development by creating an account on GitHub.
github.com
* converter-gson
https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-gson
* logging-interceptor
https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor
'Android Studio' 카테고리의 다른 글
[Android Studio] 액션바 만들고, 해당 엑티비티에서 액션바 보이게 만드는 함수 _onCreateOptionsMenu(Menu menu) (2) | 2024.06.14 |
---|---|
[Android Studio] 새로운 미니 창 뜨게하는 showAlertDialog() 함수 만들기 (0) | 2024.06.14 |
[Android Studio] 텍스트에 원하는 설정하기 _ 밑줄 (0) | 2024.06.13 |
[Android Studio] 진행상태를 표시하는 함수 _Dialog를 이용한 progress (0) | 2024.06.13 |
[Android Studio] nextPageToken을 이용한 Scroll paging 처리 방법 (0) | 2024.06.12 |