Android ProgressBar in ListView while using DownloadManager

后端 未结 3 1600
深忆病人
深忆病人 2020-12-30 13:36

I have a ListView in which each item represents a PDF file. When the user clicks on an item, the application must download the file on external storage. Now the download doe

3条回答
  •  一个人的身影
    2020-12-30 14:14

    Please note that DownloadManager.enqueue is asynchronous, it means mgr.enqeue returns almost immediately and after that your current code sets spinner back to invisible.

    To hide spinner you have to register a broadcast receiver to receive notification when download completes. You then have to find corresponding spinner and hide it. Please note that download can fail (and notification is still sent in this case).

    CommonsWare has posted an example showing how to work with DownloadManager.

提交回复
热议问题