retrofit2

Why the build process ignore proguardFiles getDefaultProguardFile('proguard-android.txt')

你说的曾经没有我的故事 提交于 2019-12-24 10:16:14
问题 All the while, I don't have any issue with my build process. I'm using latest build.gradle . I'm using Android Studio 3.1.3. build.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.google.gms:google-services:3.2.0' } } allprojects { repositories { google() jcenter() maven { url "https://jitpack.io" } } }

Android (Java) - POST (with headers) with Retrofit 2.1.0

倖福魔咒の 提交于 2019-12-24 08:38:40
问题 I need to integrate a RESTful API called SMMRY into my Android App. This API does automatic text summary of an URL or block of text that is sent to it. I am using Retrofit 2.1.0 as networking library. I have managed to put URL text summarization working perfectly, so when I pass the URL then it does the text summary and provides me back. But I am unable to correctly implement the POST request by sending the appropriate parameters (which include headers, etc), so that it does the summary of

android paging library - which DataSource I should use

两盒软妹~` 提交于 2019-12-24 08:34:04
问题 What I Want: I want to implement Android Paging Library with network call only. What I Understood: So, DataSource has three classes that I can extend. PageKeyedDataSource: If your web service has pageNumber in url then you can use it. ItemKeyedDataSource: When you are fetching nested data then you can use it. For example getting replies on particular comment. PositionalDataSource: You can use when you know exact number of data is going to load. What I Tried : Code is below. MainActivity.java

Android Retrofit 2.0 JSON document was not fully consumed

守給你的承諾、 提交于 2019-12-24 08:28:39
问题 I am using retrofit 2.0 to post data in the form of post request with pojo class and returning string as an response either failure or success and now the problem is that it says json cannot be consumed. compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.google.code.gson:gson:2.6.1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' compile 'com.squareup.okhttp:okhttp:2.4.0 Now I am trying to post jsonobect as like below. My pojo class is as below public class

OkHttp Authenticator sometimes does not call authenticate on HTTP 401

流过昼夜 提交于 2019-12-24 08:25:32
问题 I have an issue that OkHttp 's Authenticator does not call the authenticate method in some cases of HTTP 401 errors. Interceptors are always called, but authenticator is sometimes called and sometimes not. Once it does not call it it will not call it for several minutes and all network calls will fail with HTTP 401. Then after 5-6 minutes it will "unstuck" and call the authenticate method again. I use it for refreshing token. If the token expiration is set to one hour, there are no issues,

Catching 401 and refreshing Firebase Id Token

爱⌒轻易说出口 提交于 2019-12-24 08:06:11
问题 My app uses Firebase to authenticate users by phone number, a migration from Digits. I add the idToken from Firebase to my calls. I listen with an interceptor on my httpclient if a 401 was trown, if so, I logged out. I noticed after one hour the 401 came in, so I added an addIdTokenListener in my App class. When it changes I update my token to sign my calls. It worked, but not flawless, sometimes a 401 was thrown and I still logged the user out... I am writing something in my interceptor to

Is it possible to POST a package of json objects?

一笑奈何 提交于 2019-12-24 07:37:52
问题 so I am building an applications that has to POST a json array with some information and also json object with user credentials which are going to be used for identification. Is is possible to POST some kind of package that contains json object array + object with user credentials? I am using Retrofit2. So beside this Array list I would like to send Credentials with one POST request. public interface JsonPlaceHolderApi { @POST("hws/hibisWsTemplate/api/v1/order/posts/") Call<Post> createPost(

Log response body in case of exception

强颜欢笑 提交于 2019-12-24 06:41:55
问题 I am using retrofit for http calls with gson as a converter. In some cases I get exceptions thrown when gson tries to convert response to object and I would like to know what is the actual response in such case. For example: This is the exception message I get: Expected a string but was BEGIN_OBJECT at line 1 column 26 path $[0].date The code that execute the call is like this: Gson gson = gsonBuilder.create(); Retrofit retrofit = (new retrofit2.Retrofit.Builder()).baseUrl(baseUrl)

What will happen if every request has a retrofit instance?

浪子不回头ぞ 提交于 2019-12-24 05:51:58
问题 I was thinking about a question recently. If every request has a retrofit instance,What will happen? The reason I want every request has a retrofit instance: Every retrofit instance has an OkHttpClient instance ,so I want add Interception to OkhttpClient,but not every request should be intercepted ,and I also want to add some same headers to OkHttpClient,but not every request must has these same headers ,like when it's login request,I don't need add token.,but other request may need. So my

Android Retrofit GET @Query ArrayList

人走茶凉 提交于 2019-12-24 04:51:12
问题 I am trying to consume a GET API that expects in its query params list an array of strings. I am using Retrofit for the task. In the API interface, I have the following defined: @GET("user/explore") Observable<User> fetchUsers(@Query("who") String who, @Query("category") ArrayList<String> categories); I am using Timber for logging and in the console, I see the request is made like the following: http://192.168.2.208:3000/api/v1/user/explore?who=SOME_USER&category=SOME_CATEGORY The expected