retrofit2

php : reading json arraylist and saving data in mysql?

感情迁移 提交于 2019-12-10 11:58:11
问题 I want to read arraylist from android into php in order to store in database , but I'm not able to find exact code for it. Can anybody guide me in the direction to solve this problem ? Here is my java code for creating the arraylist private void loadCart() { productList.clear(); Cursor cursor = dbHelper.getCarProducts(); cursor.moveToFirst(); do { CartProduct cartProduct = new CartProduct(); cartProduct.setProductName("Name: "+cursor.getString(cursor.getColumnIndex("_Name"))); cartProduct

D/OkHttp: <— HTTP FAILED: javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x64e3c938: I/O error during system call, Connection reset by peer [duplicate]

穿精又带淫゛_ 提交于 2019-12-10 11:46:16
问题 This question already has answers here : javax.net.ssl.SSLException: Read error: ssl=0x9524b800: I/O error during system call, Connection reset by peer (5 answers) Closed 12 months ago . D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x64e3c938: I/O error during system call, Connection reset by peer I'm getting this error on an Android 4.2.2 device. While running the same application on other devices, it works fine. Please Help. public static Retrofit

How can I set connection timeout in Retrofit library for Android?

眉间皱痕 提交于 2019-12-10 10:54:00
问题 I have used Retrofit library for my Android application.I need to set connection timeout as 120 Sec. How can I do ? Version: compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.google.code.gson:gson:2.8.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' OperatingApiClient: public class OperatingApiClient { public static final String BASE_URL = "http://172.16.2.39/"; private static Retrofit retrofit = null; public static

Retrofit2/OkHttp 重写覆盖headers 与 不重写覆盖Headers

守給你的承諾、 提交于 2019-12-10 07:45:09
台风海马来深圳了,下面的虽然是英文,但是感觉比中文更容易让人看懂 Add Request Headers Adding HTTP request headers is a good practice to add information for API requests. A common example is authorization using the Authorization header field. If you need the header field including its value on almost every request, you can use an interceptor to add this piece of information. This way, you don’t need to add the @Header annotation to every endpoint declaration. OkHttp interceptors offer two ways to add header fields and values. You can either override existing headers with the same key or just add them without checking if there

Handling Error RXJava Android with Kotlin

假装没事ソ 提交于 2019-12-10 04:29:04
问题 Hi I'm new with RxJava and Kotlin and I loose some concepts about it. I have "api" like this: interface VehiclesService { @GET("/vehicles/") fun getVehicles(): Single<List<Vehicle>> } Then I create the retrofit client, etc.. like this: var retrofit = RetrofitClient().getInstance() vehiclesAPI = retrofit!!.create(VehiclesService ::class.java) finally I do the call: private fun fetchData() { compositeDisposable.add(vehiclesAPI .getVehicles() .subscribeOn(Schedulers.io()) .observeOn

Dagger2 cannot access nullable. javax.annotation.Nullable not found

家住魔仙堡 提交于 2019-12-10 04:28:55
问题 I have a module to provide a Retrofit interface. @Module class NetModule(val base: String) { @Provides @Singleton fun provideOkHttpClient(): OkHttpClient { return OkHttpClient.Builder() .addInterceptor(object: Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val request = chain.request() info("Request for ${request.url()}") return chain.proceed(request) } }).build() } @Provides @Singleton fun provideGson(): Gson { return GsonBuilder()

Retrofit2 再次封装(API not restful)

有些话、适合烂在心里 提交于 2019-12-10 02:56:41
前言 后期Retrofit(与Rxjava2结合)相关更改放在: https://github.com/AnyLifeZLB/AndroidAppFrameWork Retrofit2 官方: http://square.github.io/retrofit Retrofit2 使用注意点总结: https://futurestud.io/tutorials/tag/retrofit 如果所有api 返回格式都和github api v3 一样Restful 根据服务器的api再次封装一下,个人推荐下面的简洁访问样式(api 由github 提供) // List your repositories @GET("/user/repos") Call<List<Repositories>> getRepositories(@Query("page") int page); //获取Repositories 数据 ! private void getRepositories(final int page){ Call<List<Repositories>> newsCall = HttpCall.getApiService(mActivity).getRepositories(page); newsCall.enqueue(new HttpCallBack<List

Polling to Backend API in regular interval for certain number of times in a regular interval - Retrofit & RxJava

痞子三分冷 提交于 2019-12-09 19:36:29
问题 I am looking to poll the backend call for certain number of times for a predefined regular intervals. I would like to exit the loop if I have received an expected payload in between the loop and update the UI else terminate the polling. Below is the code I normally do when I make standard http call. //Response Model from backend API public class ApplicationStatusResponse { public boolean isActive; } //Retrofit facade @POST(v1/api/applicationStatus) Single<ApplicationStatusResponse>

Retrofit 2.2.0 Android API 24 javax.net.ssl.SSLHandshakeException: Handshake failed

梦想与她 提交于 2019-12-09 19:17:43
问题 I'm using Retrofit 2.2.0 for uploading image to server (using Java). With an Android device (Samsung galaxy S6) API 24 (Build : NRD90M.G920FXXU5EQAC) when I try to post a request, this request failed with this error javax.net.ssl.SSLHandshakeException: Handshake failed ps: I try to downgrade the Retrofit 2.1.0 and it works perfectly. 回答1: The solution for me was adding more ciphers as acceptable for OkHttpClient. Since API 21, some TLS certificates are deprecated for Android. This might help:

RxAndroid - retry observable on click

纵然是瞬间 提交于 2019-12-09 17:53:43
问题 I'm using rxAndroid and rxKotlin in my Android app to handle network requests asynchronously. Now I would like to retry a failed network request only after click on Snackbar button. My code now: val citiesService = ApiFactory.citiesService citiesService.cities() .subscribeOn(Schedulers.newThread()) // fetch List<String> .flatMap { Observable.from(it) } // convert to sequence of String .flatMap { city -> citiesService.coordinates(city) // fetch DoubleArray .map { City(city, it) } // convert to