如何使用齐射从json获取阿拉伯数据?

时间:2019-04-15 10:19:56

标签: json encoding android-volley input-field

我试图像往常一样使用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();

0 个答案:

没有答案