Using DownloadManager, how can I see all active / running downloads from my device?
My code is:
DownloadManager.Query query = null;
Cursor c = null;
DownloadManager downloadManager = null;
downloadManager = (DownloadManager)m_context.getSystemService(Context.DOWNLOAD_SERVICE);
query = new DownloadManager.Query();
if(query!=null)
{
query.setFilterByStatus(DownloadManager.STATUS_FAILED|DownloadManager.STATUS_PAUSED|DownloadManager.STATUS_SUCCESSFUL|
DownloadManager.STATUS_RUNNING|DownloadManager.STATUS_PENDING);
}
c = downloadManager.query(query);
if(c.moveToFirst())
{
int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
switch(status)
{
case DownloadManager.STATUS_PAUSED:
break;
case DownloadManager.STATUS_PENDING:
break;
case DownloadManager.STATUS_RUNNING:
break;
case DownloadManager.STATUS_SUCCESSFUL:
break;
case DownloadManager.STATUS_FAILED:
break;
}
}
Failed to execute c.moveToFirst () function (returns false);
Does DownloadManager have any special permission?
source
share