When I remove the requestQuery.add() line - all works fine except absence of network data. After adding requestQuery.add() - I'm getting this:
Traceback:
08-29 18:15:53.071 6305-7075/? E/dalvikvm-heap﹕ Out of memory on a 840969348-byte allocation.
08-29 18:15:53.141 6305-7075/? E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-27227
java.lang.OutOfMemoryError
at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:322)
at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:540)
at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:562)
at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader(DiskBasedCache.java:403)
at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:156)
at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:84)
Here's the code I have:
public class DataReceiver {
public static void initializeCountriesListUpdate(String urlString, final Context context) throws IOException {
RequestQueue requestQueue = Volley.newRequestQueue(context);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, urlString,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
ArrayList<Country> countriesList = JsonParser.getCountriesFromJson(response, context);
((CountriesListActivity)context).updateCountriesList(countriesList);
((CountriesListActivity)context).progressDialog.hide();
((CountriesListActivity)context).progressDialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("NetworkManager", "Cannot resolve data from the server");
}
});
VolleySingleton.getInstance().getRequestQueue().add(jsonObjectRequest);
}
UPD1:
I tried to add
android:hardwareAccelerated="false"
android:largeHeap="true"
to Manifest, but it doesn't helped.