[Solved] Retrofit give null pointer exception

When you have an error on your response, your response body is null. You have to use the code from the Response and if you want to get the data from the error use the errorBody(): public void onResponse(Call<SalaryListModel> call, Response<SalaryListModel> response) { if (response.isSuccessful()) { Log.e(TAG, “onResponse: calling”); if (response.body().getStatus_code() == 200) { Log.e(TAG, … Read more

[Solved] How to parse get roles value from this json?

your pojo class should be like this.then it will work public class MyPojo { private String[] roles; public String[] getRoles () { return roles; } public void setRoles (String[] roles) { this.roles = roles; } @Override public String toString() { return “ClassPojo [roles = “+roles+”]”; } } 1 solved How to parse get roles value … Read more

[Solved] null response usin Retrofit Library in android

Your POJO class is wrong Try this public class Products_Main { @SerializedName(“current_page”) int current_page; @SerializedName(“data”) private List<Product> products; public int getCurrent_page() { return current_page; } public void setCurrent_page(int current_page) { this.current_page = current_page; } public List<Product> getProducts() { return products; } public void setProducts(List<Product> products) { this.products = products; } } and class Product { … Read more

[Solved] Picasso recycle view retrofit 2 in grid view

Change adapter = new DataAdapter(data,context); line to adapter = new DataAdapter(data,YourActivity.this); then, go to the Adapter class, and paste public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder> { private ArrayList<dashboard.Dashboard_info> android; private Activity activity; public DataAdapter(ArrayList<dashboard.Dashboard_info> android,Activity activity) { this.android = android; this.activity = activity; } now use picasso with Picasso.with(activity).load(android.get(i) .getWeek_image()) .resize(250,200) .into(viewHolder.img_android); solved Picasso recycle view … Read more

[Solved] Retrofit 2 response body is empty or Model class is wrong. Cannot get JSON data it gives an Exception: Expected BEGIN_ARRAY but was BEGIN_OBJECT

your model is wrong it should look like this pseudo code public Response{ String status; int count; List<Category> categories; 3 solved Retrofit 2 response body is empty or Model class is wrong. Cannot get JSON data it gives an Exception: Expected BEGIN_ARRAY but was BEGIN_OBJECT

[Solved] How Retrofit library working faster than default AsyncTask? [closed]

Async task execute serially and are single threaded by default and they will wait for last call to complete before execution of next one and designed in a way so that to avoid common errors due to parallel running threads. Retrofit is not. It sends calls parallely and use ThreadPoolExecutor. 1 solved How Retrofit library … Read more