how to Get a list of applications being download?

心不动则不痛 提交于 2019-12-06 08:33:32

问题


In my application, I need to know if a particular app is being downloaded from the android market or not. How Do I achieve this functionality? Is it possible to get a list of all the downloads that are in progress?Does the android market broadcast any intents that can be caught?

Note:Since my target application is on android 3.0+ devices therefore, I have no issues with using the DownloadManager class(which is 2.3 onwards).


回答1:


I found an API that will accomplish what you want but you need to have an API of 9 or higher to use it. You can get all the downloads that have been requested for download from a download manager by using this:

DownloadManager manager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Query query = new DownloadManager.Query();
Cursor c = manager.query(query);

You can get more information on this here. I don't think there are any other methods available that will give you this information at a lower API level.




回答2:


I dont think that there are any android market application intents you can catch (but I'm not 100% sure because I can't find android market app manifest nowhere).

As I see it, through the DownloadManager.query(DownloadManager.Query q) class you should be able to find all the ongoing downloads and by source of the data you could exclude all which are not download from market.



来源:https://stackoverflow.com/questions/6941100/how-to-get-a-list-of-applications-being-download

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!