我正在使用Android DownloadManager
从服务器下载视频。我想给自己的每个视频命名。默认情况下,视频名称为downloadfile-6.bin。
String servicestring = Context.DOWNLOAD_SERVICE;
DownloadManager downloadmanager;
downloadmanager = (DownloadManager) getSystemService(servicestring);
Uri uri = Uri.parse(links.get(0));
DownloadManager.Request request = new DownloadManager.Request(uri);
Long reference = downloadmanager.enqueue(request);
建议将不胜感激。
答案 0 :(得分:3)
您可以使用DownloadManager.Request
或setDestinationInExternalFilesDir(...)
通过setDestinationInExternalPublicDir(...)
对象进行设置。见最后一行:
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle("DownloadTitle")
.setDescription("DownloadDesc")
.setDestinationInExternalPublicDir("/mypath", "filename.jpg");
<强>来源:强>