问题
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