Created
October 24, 2016 09:43
-
-
Save balrampandey19/da57598d2078b27bf802285d469a76c9 to your computer and use it in GitHub Desktop.
Retrofit 2.0 to String converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you are using Protocol buffer or Flat buffer and want to get Byte String response for server-: | |
``` | |
public class ToStringConverterFactory extends Converter.Factory { | |
@Override | |
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { | |
if (String.class.equals(type)) { | |
return new Converter<ResponseBody, String>() { | |
@Override | |
public String convert(ResponseBody value) throws IOException { | |
return value.string(); | |
} | |
}; | |
} | |
return null; | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retrofit 2.0 to String converter