1

我有这个代码供下载管理器下载,

代码:

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;
        }
    }

现在我想当点击通知中的下载处理时,当前下载被取消。

4

1 回答 1

0

如果要取消对下载通知的下载操作,则需要使用自定义通知而不是内置通知。或者您可以使用用户在通知中单击的取消操作打开下载列表

您可以在此处阅读有关下载管理器单击操作的更多信息

于 2015-04-13T06:55:05.697 回答