Skip to main content

Posts

Showing posts from December, 2014

Custom Volley-Gson request implementation

This page covers Volley-Gson integration and also Volley custom Request . We assume that, you are familiar with Volley and Gson . Volley has some inbuilt request which you can use, if your response is a String , Image , or JSON , in that case, you don't need to implement a custom Request .  To use Gson with Volley , we need to implement a custom request. To make a custom request, you need to perform following operation. Extend Request<T> class, where T is the type of parsed response or expected response. Implement the abstract methods parseNetworkResponse() and deliverResponse() .  parseNetworkResponse:  A response contains parse response of a given type i.e Gson. @Override     protected Response<T> parseNetworkResponse(NetworkResponse response) {         try {             String json = new String(                     response.data, HttpHeaderParser.parseCharset(response.headers));             if (BuildConfig.IS_DE