Last active
April 27, 2024 17:45
-
-
Save nikzad-avasam/ee56c2f1fba8580f34d7c609d081f02d to your computer and use it in GitHub Desktop.
Use this class instead JsonArrayRequest OR JsonObjectRequest in Volley Library for support UTF-8 Languages Like Persian ( FARSI )
This file contains hidden or 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
/** | |
* Created by Sam Nikzad on 5/27/2016. | |
*/ | |
public class JsonArrayRequestUtf8 extends JsonArrayRequest { | |
public JsonArrayRequestUtf8(String url, Response.Listener<JSONArray> listener, Response.ErrorListener errorListener) { | |
super(url, listener, errorListener); | |
} | |
@Override | |
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { | |
try { | |
String json = new String( | |
response.data, | |
"UTF-8" | |
); | |
return Response.success( | |
new JSONArray(json), | |
HttpHeaderParser.parseCacheHeaders(response) | |
); | |
} catch (UnsupportedEncodingException e) { | |
return Response.error(new ParseError(e)); | |
} catch (JSONException e) { | |
return Response.error(new ParseError(e)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By This Class You Can Use JsonArrayReques for UTF-8 Languages Like Persian ( Farsi ) & Arabic and etc.
how to use :
create new class file in your project and copy this class codes and Now use your class name instead of JsonArrayRequest .
you can use this class instead of JsonObjectRequest Too.
پشتیبانی فارسی در کتابخانه ی Volley
Volley UTF-8 Languages Support