如何使用DownloadManager查看设备上所有正在进行的下载?
我的代码:
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;
}
}
在c.moveToFirst()函数上失败了(返回false);
DownloadManager是否需要一些特殊的权限?