---
title: "判断系统是否支持 DownloadManager服务"
author: "Darar"
date: "2013-03-18T14:25:34Z"
tags: []
categories: ["移动开发"]
slug: "downloadmanager"
draft: false
lastmod: "2013-03-18T14:25:34Z"
id: 1831175
url: "https://darar.iteye.com/blog/1831175"
---

public static boolean isDownloadManagerAvailable(Context context)
    {
        try
        {
            Log.d("Download", "Build.VERSION.SDK_INT is " + Build.VERSION.SDK_INT);
            Log.d("Download", "Build.VERSION_CODES.GINGERBREAD is " + Build.VERSION_CODES.GINGERBREAD);
            if(Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
            {               
                return false;
            }
            Log.d("download", "can download");
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList");
            List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
            Log.d("Download", "List size is " + list.size());
            return list.size() > 0;
        }
        catch(Exception e)
        {
            return false;
        }
    }