retrofit2

How to fix Expected Android API level 21+ but was 19 in Android

大憨熊 提交于 2019-12-08 04:24:08
问题 In my application i want get data from server, for get connect to server i used Retrofit , OkHttp . But when running application, show me force close error. In android api 21+ is not error, but below api 21 show me force close error. ApiClient class codes: class ApiClient constructor(private val deviceUUID: String) { private val apiServices: ApiServices init { //Gson val gson = GsonBuilder() .setLenient() .create() //Http log val loggingInterceptor = HttpLoggingInterceptor()

Retrofit 2 Error: java.net.SocketTimeoutException: failed to connect to /192.168.86.1 (port 8080) after 10000m

試著忘記壹切 提交于 2019-12-08 04:20:11
问题 I'm trying to make my App connect to a local web service using Retrofit 2 but i'm always getting this error. I'm sure the web service is responding because i'm using a tool in firefox that make the @GET request and the return is OK, returns me the correct JSON. In android it doesn't even connect. This is my MainActivity: public class MainActivity extends AppCompatActivity { private String API_BASE_URL="http://192.168.1.32:8080/economarket-restService/resources/androidTest/"; @Override

Retrofit is returning cached response

北慕城南 提交于 2019-12-08 04:08:58
问题 I am using Retrofit in an Android application. When I hit an API with token to get user information it gives cached(previous) response. Whenever I logged out and log in again API gives previous user detail, I tested API in Postman it works fine there. I have tried some solutions I searched but nothing is working. Response header that I am getting is Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 Server: Kestrel Date: Mon, 08 Jan 2018 09:35:26 GMT Below is ApiClient

How do I implement a webhook in Android?

夙愿已清 提交于 2019-12-08 04:00:33
问题 I want to have URL for example www.example.com/status in my Android app to which I will be observing and will be receiving multiple POST requests from the Server. With each POST request, I will trigger a feature. I don't understand how can I implement a listener on a URL 24x7. All I want is a place to start with. If this is not possible then is Push Notifications a viable option? Note: The webhook isn't supposed to be on the Server instead it should be on the Client (Android) and Server is

How to skip proguard models used by retrofit2 that is on the base package?

只愿长相守 提交于 2019-12-08 03:38:10
问题 I am writing an application with Kotlin and Retrofit 2. As I use proguard, I follow the rules here: https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-square-retrofit2.pro Besides I also need to proguard my models too, as stated in https://stackoverflow.com/a/41136007/3286489 It works fine if I have my models in a package, and I have -keep class com.elyeproj.wikisearchcount.model.** { *; } package com.elyeproj.wikisearchcount.model object Model { data class

Retrofit not retrieving AccessToken

泄露秘密 提交于 2019-12-08 03:17:19
问题 I have been following this tutorial as I have been advised that Retrofit is the best API to use for oAuth and network calls: Retrofit oAuth2 tutorial It seems to have been working well and I had retrieved my authorization code without any problems. However, when It came to using the code they supplied for exchanging it for an Access Token, I seem to be getting a nullpointer and being a total beginner with Retrofit I am not sure what I am doing wrong. ServiceGenerator Class: public class

How to set dynamic filename?

[亡魂溺海] 提交于 2019-12-08 02:17:13
问题 Using retrofit 2, how would I set a dynamic name for the uploaded file? Currently, it's like this: @Part("avatar\"; filename=\"image\" ") RequestBody image, However, the uploaded file name would be image without the extension. Any recommendation on this case? 回答1: Define your endpoint with MultipartBody.Part as the type: interface Example { @Multipart // @POST("/foo/bar/") // Call<ResponseBody> method(@Part MultipartBody.Part part); } and then use its factories to create the type: RequestBody

How to make multiple calls with Retrofit?

…衆ロ難τιáo~ 提交于 2019-12-08 01:57:31
问题 I need to make multiple calls to API REST with Retrofit and show the response in a ListView , but I don't know how to do this and this code doesn't work. Model @GET("apks/{sha256}") Call<DatoAPI> getTask2(@Path("sha256") String hash, @Query("Authorization") String key); Implementation for (String s: hash) { Call<DatoAPI> call = services.getTask2(s, API.API_KEY); call.enqueue(new Callback<DatoAPI>() { @Override public void onResponse(Call<DatoAPI> call, Response<DatoAPI> response) { if

Android: Can not construct instance of java.sql.Timestamp from String value

☆樱花仙子☆ 提交于 2019-12-08 01:06:47
问题 I have developed a REST API and I am trying to connect to it using Android. Below is my code. private void restCall() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(URL) .addConverterFactory(GsonConverterFactory.create()) .build(); YourEndpoints request = retrofit.create(YourEndpoints.class); SetupBean setupBean = new SetupBean(); setupBean.setIdPatient(1); setupBean.setCircleType(1); setupBean.setFamiliarity(1); setupBean.setValence(2); setupBean.setArousal(3); setupBean

Retrofit Android basic and simple issue

天大地大妈咪最大 提交于 2019-12-08 00:27:13
问题 My server returns simple Json result like below, {"message":"Upload Success.!"} I am trying to get the result into Retrofit Model class public class MyResponse { @SerializedName("message") String message; } My interface class is here public interface MyService { @Multipart @POST("/") public retrofit2.Call<MyResponse> saveFile(@Part("filename") String fileName, @Part("photo") RequestBody photo); } this is how i try to fetch the result Gson gson = new GsonBuilder() .setLenient() .create();