Я пытаюсь получить данные, как всегда, используя Volley, но теперь мой JSON содержит арабские данные, и в onErrorResponse()
я получаю «unsupportedencodingexception: ошибка« utf-8 ». Вот мой код» :
public class VolleyJson implements Response.ErrorListener ,
Response.Listener<JSONArray>{
private RequestQueue requestQueue;
private Context context;
private JsonArrayRequest arrayRequest;
private String urlKitchenOrders = "http://10.0.0.16:8080/WSKitchenScreen/FSAppServiceDLL.dll/GetRestKitchenData?compno=302&compyear=2018&POSNO=1";
private JsonObjectRequest updateObjectRequest;
private ProgressDialog progressDialog;
public VolleyJson(Context context) {
this.context = context;
this.requestQueue = Volley.newRequestQueue(context);
progressDialog = new ProgressDialog(context);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("Please Wait...");
progressDialog.setCancelable(false);
}
public void sendKitchenRequest() {
progressDialog.show();
arrayRequest = new JsonArrayRequest(Request.Method.GET, urlKitchenOrders, null, this, this);
requestQueue.add(arrayRequest);
}
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
Log.e("kitchen: getOrders", "" + error);
}
@Override
public void onResponse(JSONArray response) {
Log.e("log", "" + encodingJson(response.toString()));
}
}
В MainActicity:
VolleyJson obj = new VolleyJson(MainActivity.this);
obj.sendKitchenRequest();