我有这段代码供下载管理器下载
代码:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription(name);
request.setTitle("دانلود ویدیو");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
request.setDestinationInExternalPublicDir("/mlindr/101ideas/video", video);
// get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
//manager.enqueue(request);
long id = manager.enqueue(request);
下载类别:
public static boolean isDownloadManagerAvailable(Context context) {
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
return false;
}
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList");
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
} catch (Exception e) {
return false;
}
}
现在我想当点击下载处理通知时,当前下载被取消。
如果您想取消对下载通知的下载操作,您需要使用自定义通知而不是内置通知。或者你可以打开下载列表,用户点击通知即可取消操作
您可以在这里阅读更多关于下载管理器点击操作的信息