Volley slow and causing memory leak

前端 未结 3 1452
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 13:08

In my project, I am using volley to download a JSON stream which I parse and show in a listview. I use the following method to load my data:

private void lo         


        
3条回答
  •  渐次进展
    2021-01-03 13:46

    i have some problem with:

    Volley.newRequestQueue(getApplicationContext());
    

    it caused the first request at startup to take awfully long time in some phones. i changed it to:

    Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024);
    Network network = new BasicNetwork(new HurlStack());
    mRequestQueue = new RequestQueue(cache, network);
    mRequestQueue.start();
    

    That solved my issue.

提交回复
热议问题