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;
}
}
判断系统是否支持 DownloadManager服务
猜你喜欢
转载自darar.iteye.com/blog/1831175
今日推荐
周排行