سؤال

I am trying to create a custom download activity/page, and I plan to build it on top of the Android DownloadManager. But seems DownloadManager has no public sorting options, all the sorting stuff is hidden, is there a way around this? I'd like to sort by date, or file size.

Thanks,

Johnny

هل كانت مفيدة؟

المحلول

In source code you can find that DownloadManger. Query can only be sorted by lastModifyDate. So I use the way to extract using source code of DownloadManger and rewrite its sorted method.

Using like this:

AppDownloadManager.Query query = new AppDownloadManager.Query();
query.setFilterByStatus(AppDownloadManager.STATUS_PENDING | AppDownloadManager.STATUS_PAUSED | AppDownloadManager.STATUS_RUNNING | AppDownloadManager.STATUS_FAILED);
query.orderBy(AppDownloadManager.COLUMN_ID, AppDownloadManager.Query.ORDER_DESCENDING);

It's first time I answer question in StackOverFlow and I think my English is poor .tks

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top