Handle OnErrorResponse Method - Volley
Handle OnErrorResponse Method - Volley I'm fetching data from a server in json format using volley. Everything works fine when connected to Wifi. But when user is connected to mobile data and especially if mobile data connection is slow OnErrorResponse method is called. I have put a Toast message in OnErrorResponse method. In some devices this toast message crashes with NullPointerException while in others it runs fine. Also if I wait for a long time, and the results are not yet displayed then app crashes with outofmemory error. Please help me. How to handle these problems efficiently? Code: private RequestQueue songQueue = songQueue = Volley.newRequestQueue(getContext()); private void getNewSongs() { JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, newSongsUrl, null, new Response.Listener<JSONObject>() { @SuppressLint("LongLogTag") @Override public void onResponse(JSONObject response) { JSONObj...