Retrofit : Retrofit is a REST Client for Java and Android
Retrofit uses the OkHttp library for HTTP requests.
Retrofit쓰는 이유
Http개발을 빠르고 쉽게한다
통신 속도가 빠르다 .
Json 구조의 데이터를 쉽게 가져올 수 있다.
>> 서버와 통신하기 위한 라이브러리로 사용하면 서버와 통신 작업이 편해진다.
사용법
1. 라이브러리 추가
2. 권한 설정
>> 인터넷 권한
3. 데이터 모델 클라스 생성
>>
@SerialzedName
JSON으로 serialize 될 때 매칭되는 이름을 명시하는 목적으로 사용
@Expose
object 중 해당 값이 null일 경우, json으로 만들 필드를 자동 생략해 준다.
4. 어떤 형태와 방식으로 통신을 할지 어노테이션과 파라미터를 지정
서버의 api가 String을 반환한다고 가정하면
클라이언트는 Retrofit을 통해 Call<String.>을 받게 된다.
5. retrofit객체 초기화 후
6. enque()에 대한 Callback 값으로 데이터 사용.
[Android/kotlin] okhttp & retrofit으로 json 파싱하기
OkHttp란? http를 더 간편하고 효율적으로 쓸 수 있도록 돕는 라이브러리 Retrofit이란? 안드로이드 앱에서 restful 통신을 할 수 있도록 도와주는 라이브러리 ※ restful 이란? devyul.tistory.com/entry/Network..
devyul.tistory.com
https://velog.io/@24hyunji/Retrofit-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
[Android/Kotlin] Retrofit 사용하기
안드로이드 스튜디오에서 HTTP통신을 위한 Retrofit 라이브러리
velog.io
https://studyandlearn.tistory.com/415
Android - Retrofit
https://square.github.io/retrofit/ Retrofit 쓰레드 돌리고 콜백도 해주고 오브젝트도 만들어 준다. rest template 버전은 낮춰봐야한다. 최신 꺼 쓰지말고 gson 어노테이션 @SerialzedName JSON으로 serializ..
studyandlearn.tistory.com
https://square.github.io/retrofit/
Retrofit
A type-safe HTTP client for Android and Java
square.github.io
https://salix97.tistory.com/204
레트로핏 (Retrofit) 이란? (Kotlin 으로 레트로핏 사용)
1. retrofit 의 뜻 안드로이드에서 retrofit 이 무엇인지 알아보기 전에, retrofit 이라는 단어의 사전적인 의미부터 알아보자. (1) 기존에 사용할 수 없었던 필요하다고 간주되는 새 부품이나 개조된 장
salix97.tistory.com
'IT > Android' 카테고리의 다른 글
Kotlin] 문자열합치기 joinToString (0) | 2022.06.20 |
---|---|
Android] Targeting s+ (version 31 and above) requires that one of flag_immutable or flag_mutable 대응 / 안드로이드 12 (0) | 2022.06.16 |
Android Studio] Api 키 숨기기 #gitIgnore (0) | 2022.05.11 |
Android] 키보드 보이기 숨기기 #windowSoftInputMode (0) | 2022.05.05 |
Android] 설정화면 구성하기 #preference (0) | 2022.05.03 |
댓글