Android提供的下载类DownloadManager
- Usage
String downUrl = "http://downloads.jianshu.io/apps/haruki/JianShu-1.11.2.apk";
/**获得系统下载器*/
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
/**设置下载地址*/
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downUrl));
/**设置下载文件的类型*/
request.setMimeType("application/vnd.android.package-archive");
/**设置下载存放的文件夹和文件名字*/
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "JianShu-1.11.2.apk");
/**设置下载时或者下载完成时,通知栏是否显示*/
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle("Download");
/**执行下载,并返回任务唯一id*/
long enqueue = dm.enqueue(request);