Android下载工具DownloadManager

慕阳文
2023-12-01
  val request = DownloadManager.Request(Uri.parse("https://bkimg.cdn.bcebos.com/pic/5243fbf2b2119313df3c27b56c380cd791238dbc?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UxODA=,g_7,xp_5,yp_5/format,f_auto"))
        //设置通知栏的标题
        request.setTitle("下载");
        //设置通知栏的message
        request.setDescription("。。。。正在下载.....");

        //设置文件存放目录
        request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS,"update.apk");
        //获取系统服务
        val downloadManager : DownloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager;
        //进行下载
        val enqueue = downloadManager.enqueue(request);

 

 类似资料: