I am developing my project using volley library .
When I analyze the data, it sometimes causes an error when there is any network problem or server-side failure, I want to display this error message with a toast, but I canโt deal with it and not show the toasts by volleyball error. Therefore, I want to manage this problem using a broadcast receiver. If possible, please give me some suggestion or solution to solve this problem. My toast code on error using volley:
mRequestQueue = Volley.newRequestQueue(context); JsonObjectRequest jr = new JsonObjectRequest(Request.Method.POST, url, jsonReq, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.i("response", response.toString()); dataObj.loadData(response); if(flag){ context.startActivity(intent); } } }, new Response.ErrorListener() { @SuppressLint("ShowToast") @Override public void onErrorResponse(VolleyError error) { Toast.makeText(context, error.toString(), Toast.LENGTH_LONG); Log.e("Json parse error", error.toString()); } });
source share