본문 바로가기

레트로핏6

레트로핏 @Field parameters can only be used with form encoding. 오류 해결 인터페이스 셋팅하실때 @FormUrlEncoded 어노테이션 하나 붙이시면 해결됩니다. 2022. 8. 2.
안드로이드 코틀린(Kotlin) 멀티파트(Multipart)를 이용하여 웹으로 사진 전송 우선 라이브러리 먼저 추가해줍니다. implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.squareup.retrofit2:converter-gson:2.1.0' 그리고 레트로핏 기본 셋팅부터 하도록 하겠습니다. import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory impo.. 2022. 1. 17.
Android polling(폴링) 백그라운드에서 API통신 해보기. 안드로이드에서 백그라운드딴에서 앱이 종료되도 주기적으로 서버와 통신하며 상태를 확인해보는 작업을 해볼게요. 프로젝트에서 오른쪽 클릭해서 new - Service - Service 해서 서비스를 상속받는 클래스를 만들어주세요 (안드로이드 4대 컴포넌트!!) public class MyService extends Service { public MyService() { } @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException("Not yet implemented"); } } 이게 초기상태로 작성된 서비스.. 2021. 7. 2.
안드로이드 retrofit2(레트로핏2)를 이용한 통신예제 (1) 저는 주로 데이터베이스의 정보를 긁어올때 사용하던 방법입니다. 우선 build.gradle (:app) 에다가 라이브러리를 추가해주겠습니다. implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' implementation 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'com.googlecode.android-query:android-query:0.25.9' implementation 'com.squareup.okhttp3:okhttp:3.3.1' implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0' im.. 2020. 12. 8.