I got problem with data server get a xml data with this: "?xml version="1.0" encoding="UTF-8" standalone="yes"?" and string can't show me special chars ( paź ), how can i fix it? I tried to change the encoding on UTF-8 and UTF-16 but didn't work or my way was bad. Any idea?
public boolean loadDataFromRest( Context context){
String szUrl = "http://host";
alertDialogBuilder = new AlertDialog.Builder( context );
StringRequest stringRequest = new StringRequest( Request.Method.GET, szUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String szResponse) {
Log.d("DEBUG ", szResponse);
}
You can try following code to debug your response. I am getting all the body contents in response.data but not in StringResponse that uses parseCharset()
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String StringResponse = "";
try {
StringResponse = new String(response.data,
HttpHeaderParser.parseCharset(response.headers));
HttpHeaderParser.parseCharset(response.headers);
Log.d(TAG, "--> Response Headers " + response.headers);
Log.d(TAG, "--> String Status Code " + response.statusCode);
Log.d(TAG, "--> String response data : " + new String(response.data));
System.out.println("--> string response is " + StringResponse);
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
}
return super.parseNetworkResponse(response);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With