Android 自定义下载通知
根据另一个SO答案,我使用以下代码行下载媒体文件:Android 自定义下载通知,android,android-download-manager,Android,Android Download Manager,根据另一个SO答案,我使用以下代码行下载媒体文件: DownloadManager.Request r = new DownloadManager.Request(Uri.parse(uri)); // This put the download in the same Download dir the browser uses r.setDestinationInExternalPublicDir(Environment.DIRECTORY_
DownloadManager.Request r = new DownloadManager.Request(Uri.parse(uri));
// This put the download in the same Download dir the browser uses
r.setDestinationInExternalPublicDir(Environment.DIRECTORY_PODCASTS, fileName);
// When downloading music and videos they will be listed in the player
// (Seems to be available since Honeycomb only)
r.allowScanningByMediaScanner();
// Notify user when download is completed
// (Seems to be available since Honeycomb only)
r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
// Start download
DownloadManager dm = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
dm.enqueue(r);
现在,除了我有几个问题外,这些都很好:
不言自明。你成功了吗?没有,我没有succeeded@AZ_终于发现了。
// Changing the Notification Title, Description, and its Visibility
DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse("///.mp3");
DownloadManager.Request req = DownloadManager.Request(uri);
req.setTitle("Download");
req.setDescription("Kick Ass Description");
req.setVisibility(Request.VISIBILITY_VISIBLE_COMPLETION_ONLY);