java - DownloadManager 来自资产文件夹的文件?(安卓工作室)
问题描述
我正在制作一个音板应用程序,我希望用户能够从资产下载文件,以便他们可以将其设置为通知声音/铃声。我收到一条错误消息,提示我只能从 HTTP/HTTPS 下载文件。有没有解决的办法?
DownloadManager.Request request = new DownloadManager.Request(Uri.parse("content://com.thingy.app/" + filename));
request.setDescription("Soundbite from ");
request.setTitle(filename);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
解决方案
推荐阅读
- java - 在 Heroku 上设置 PostgreSQL 数据库(需要 entityManagerFactory)
- ios - 将大量数据从 iPhone 发送到后端服务
- javascript - 从单选按钮更改和存储值
- python - 如何修复 Telethon 的异常 BadMessageError
- html - 在较高 z-indexed 元素上较低 z-indexed 父母的孩子?
- spring-boot - 在 jhipster 中将 http 重定向到 https
- methods - 这个具体的方法叫什么?
- node.js - 无法使自定义命名的本地策略在 PassportJS 中起作用
- python - Python作业与while循环打印输出
- html - Reactjs - 调整大小时排序div