英文:
Problem downloading files from link android java
问题
我有一个链接,如果我们访问它,.mp4 文件将会自动下载,但如果尝试使用下载管理器下载,则文件将以 .html 格式保存,我想要的是 .mp4 格式。
String ID = "https://presaver.com/download/9Tw-f3i-08k/22";
DownloadManager downloadmanager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(ID);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setTitle("YoutubeVideo");
request.setDescription("下载 YouTube 视频");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setVisibleInDownloadsUi(true);
request.setDestinationUri(Uri.parse(path));
downloadmanager.enqueue(request);
<details>
<summary>英文:</summary>
I have a link where if we go, the .mp4 file will be downloaded automatically, but if the try to do using the download manager then the files is saved as .html format which I want in .mp4.
String ID = "https://presaver.com/download/9Tw-f3i-08k/22";
DownloadManager downloadmanager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse("ID");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setTitle("YoutubeVideo");
request.setDescription("Downloading youtube video");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setVisibleInDownloadsUi(true);
request.setDestinationUri(Uri.parse(path));
downloadmanager.enqueue(request);
</details>
# 答案1
**得分**: 1
我认为您在这行代码中写错了:
```java
Uri uri = Uri.parse("ID");
应该改为:
Uri uri = Uri.parse(ID); // 字符串 ID
英文:
I think you miswrote this line
Uri uri = Uri.parse("ID");
It should be
Uri uri = Uri.parse(ID); // string ID
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论