我正在使用 DownloadManager 从 URL 下载 xml 文件。它工作正常,但我有两个问题:
1.) 如何在关闭的通知栏中显示有关下载的消息?我可以在打开栏时显示一条消息,如下图所示:
2.) 如何以编程方式删除 tis 通知?
我的下载管理器代码:
//Download XML file from URL
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(URL));
request.setTitle("Download von "+Name+".xml");
request.setDescription("Download von "+Name+".xml");
// in order for this if to run, you must use the android 3.2 to compile your app
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalPublicDir(FileSeperator+"XML"+FileSeperator, Name + FileExtension);
// get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);