从链接android java下载文件时出现问题
我有一个链接,如果我们去的话,.mp4文件将被自动下载,但是如果尝试使用下载管理器,那么文件将被保存为.html格式,我想要在.mp4中从链接android java下载文件时出现问题,java,android,download,Java,Android,Download,我有一个链接,如果我们去的话,.mp4文件将被自动下载,但是如果尝试使用下载管理器,那么文件将被保存为.html格式,我想要在.mp4中 String ID = "https://presaver.com/download/9Tw-f3i-08k/22"; DownloadManager downloadmanager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
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);
我想你写错了这句话
Uri uri = Uri.parse("ID");
应该是
Uri uri = Uri.parse(ID); // string ID
(Uri.parse(path))
路径的值是多少?或者尝试将https
更改为http
。