retrofit

How to pass json in request using retrofit services in android studio

时光怂恿深爱的人放手 提交于 2019-12-13 10:13:25
问题 How Can I pass the request data in these type of request in retrofit. 回答1: Main thing to consider is Gson gson = new Gson(); String strJsonObject = gson.toJson(OBJECT_OF_YOUR_MODEL_CLASS); strJsonObject is string value you can pass as parameter Here is a code snip how you can achieve it .. ObjectModel objectModel = new ObjectModel(); objectModel.setMobile_number("123456789"); objectModel.setWork_number("12345789"); objectModel.setFax_number("123465"); objectModel.setFirst_name("first name");

Android Retrofit2: How can I create expandable recycler view for categories and subcategories?

ε祈祈猫儿з 提交于 2019-12-13 08:37:47
问题 I am trying to archive this functionality for my grocery app https://imgur.com/Ugj4BIO But I am failed to do so! I am showing you what I am able to archive. if you have any Better Solution let me know. Here is my Json code from which I am fetching my data from web server right now its localhost {"cats": [{"sub_cats": [{ "sub_id":"1", "sub_title":"Charger", "sub_img":"http:\/\/localhost\/adminPohanch\/public\/img\/img23.jpg" }, { "sub_id":"2", "sub_title":"Dummy", "sub_img":"https:\/\

Using Volley without Gson

*爱你&永不变心* 提交于 2019-12-13 08:37:11
问题 Today I got to know that Retrofit uses gson(or any other convertor) to serialize or deserialize the json response (response that was got using okhttp or any related library). Now, when I was naive(in some sense still am) and I used to use Volley and at that time I never used Gson or any related library and same for okhttp.But i used to get my response and inflate it successfully on my views. 1. Now does Volley internally do what Retrofit does using Gson and Okhttp? If not? 2. Then how did i

No adapter attached; skipping layout : RecyclerView [duplicate]

孤街醉人 提交于 2019-12-13 08:19:11
问题 This question already has answers here : recyclerview No adapter attached; skipping layout (30 answers) Closed 2 years ago . MainActivity.class public class MainActivity extends AppCompatActivity { private static final String TAG = "ERROR"; private final static String API_KEY = "xxxxxxxxxxxxxx"; int totalpage; int page; int firstVisibleItem, visibleItemCount, totalItemCount; ProgressBar progressBar; RecyclerView recyclerView; MoviesAdapter moviesAdapter; private boolean makeCall = false;

Does retrofit interfaces support templated callbacks

核能气质少年 提交于 2019-12-13 08:01:31
问题 I have an API the returns a standard reply for all requests that gets parsed by gson/retrofit. public class ServerReply<T> { @Expose private String status; @Expose private T data; @Expose private String message; } I have an interface for Retrofit that will return a list of users inside of serverReply. public interface Test { @POST("/Test") void runTest(@Body Body body, Callback<ServerReply<List<User>>> response); } I would like to get a different list of objects depending on the content of

JSON Response Using Retrofit on Android

戏子无情 提交于 2019-12-13 07:49:47
问题 I'm able to get JSON response using OkHttp3, and I want to use Retrofit to parse the response to get the name and the image from it. I looked into Retrofit website and some tutorials, but still the process not clear. Here is my OkHttp3 code to get JSON response: Request request = new Request.Builder().url(url).build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { e.printStackTrace(); } @Override public void onResponse(Call call,

Retrofit 2.0 & RxJava - Custom Error Handler

▼魔方 西西 提交于 2019-12-13 07:11:43
问题 I'm using Retrofit 2.0 along with RxJava and I need to make a custom error handler so that I can get the HTTP error code. This is the example that I get, but it won't work on Retrofit 2.0, since RetrofitError is removed. @Override public void onError(Throwable e) { if (e instanceof RetrofitError) { if (((RetrofitError) e).isNetworkError()) { //handle network error } else { //handle error message from server } } } Is there any way that I can do this? Thanks. 回答1: I'm sorry that I didn't read

Android: RESTfull API called from `retrofit 2` says `Method Not Allowed`

十年热恋 提交于 2019-12-13 07:07:50
问题 I have developed a web service using Java and Jersey. Now I am trying to connect into it, call its methods and get data, using android. Below is the related part of the web service. import bean.PatientBean; import bean.UserBean; import db.PatientImpl; import db.PatientInterface; import db.UserImpl; import db.UserInterface; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws

Retrofit call to server 2.0.0Beta2, nothing happening - callback never invoked

我们两清 提交于 2019-12-13 06:17:11
问题 I make the call like such: ApiInterface.getKidMixClient(getActivity()).getAccountDetails().enqueue(LoginFragment.this); Here is my interface definition: @GET(Endpoints.GET_MY_ACCOUNT_DETAILS+"/") Call<Account> getAccountDetails(); But my callback onResponse is never being invoked? Is there something wrong with this set up? public class ApiInterface { private static ApiService apiInterface; public static ApiService getKidMixClient(final Context context) { if (apiInterface == null) {

android- Getting json values using gson and retrofit

烈酒焚心 提交于 2019-12-13 06:00:09
问题 Iam using retrofit for http calls and gson for json parsing. I referred these links: a-smart-way-to-use-retrofit and deserializing-inner-class-when-using-gson-and-retrofit. But iam getting retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ This is my json response: { "Document": [ { "Name": "name", "Password": "passwrd" } ] } This is my rest api: @GET("/ObjectTracking