Volleyball exception throws BroadCastReceiver

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()); } }); //RequestQueue mRequestQueue = Volley.newRequestQueue(this); mRequestQueue.add(jr); 
+4
source share
1 answer

I think you forgot to show a toast

 Toast.makeText(context, error.toString(), Toast.LENGTH_LONG).show(); 

Trying to enable Android Lint as often as in this case.

0
source

Source: https://habr.com/ru/post/1493119/


All Articles