Reputation: 677
I have some Unicode characters in my URL that sent using StringRequest class. Once I got them on server, They are not represent in correct format.I had same problem with receiving data from server that solved by overriding parseNetworkResponse method. What should I do for this?
StringRequest request = new StringRequest(Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// ...
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
}) {
@Override
protected Response<String> parseNetworkResponse(
NetworkResponse response) {
// TODO Auto-generated method stub
String strUTF8 = null;
try {
strUTF8 = new String(response.data, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Response.success(strUTF8,
HttpHeaderParser.parseCacheHeaders(response));
}
public java.util.Map<String, String> getHeaders()
throws com.android.volley.AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
return headers;
}
};
Upvotes: 0
Views: 1114
Reputation: 3783
Assuming the Arabic is a string, why don't you try this :
URI.encode("10.0.2.2/test.php?key=20893&rt=add&w1='تست'&w2='تست'").
Upvotes: 1