//获得系统下载器
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
//设置下载地址
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(params[0]));
//设置下载文件的类型
request.setMimeType("application/vnd.android.package-archive");
//设置下载存放的文件夹和文件名字
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "myApp.apk");
//设置下载时或者下载完成时,通知栏是否显示
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle("下载新版本");
//执行下载,并返回任务唯一id
enqueue = dm.enqueue(request);
安卓更新app
最新推荐文章于 2024-08-09 07:29:02 发布