I am downloading many files (50+) from DownloadManager by enqueue it in a for loop. On start of the download the UI freezes for a while and produces ANR. I am using volley library to access the files from the server and enqueue them in the DownloadManager.
Asked
Active
Viewed 231 times
-2
-
2Try rewriting this as a specific question. Look at this page in the Help section for guidance: https://stackoverflow.com/help/mcve – MeanGreen Nov 10 '17 at 06:49
-
I'm having the same problem. But I only call `DownloadManager.enqueue` once. – Kimi Chiu Jul 25 '18 at 15:44
1 Answers
0
if you want to get clarity to prevent an ANR error then you could visit this link
When the UI thread of an Android app is blocked for too long, an "Application Not Responding" (ANR) error is triggered.
When app needs to do long operations with background thread based like file download the you must handle in Service
Once the operation done as you needed in service then you can handle it with the help of BroadcastReceiver to make the UI changes based on the background operations.
Note: If you have good clarity on the android components(Activity, BroadcastReceiver, and Service) then you'll not face this kind of issues at your case.

Deva
- 2,386
- 1
- 16
- 16