Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Android上的DownloadManager队列下载的图像_Android_Image_File - Fatal编程技术网

从Android上的DownloadManager队列下载的图像

从Android上的DownloadManager队列下载的图像,android,image,file,Android,Image,File,我有这段代码可以下载图像,但由于某种原因,图像在我的下载中是“排队”的,而不是下载 String url = file.public_url; getContext(); DownloadManager manager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE); Uri uri = Uri.parse(url);

我有这段代码可以下载图像,但由于某种原因,图像在我的下载中是“排队”的,而不是下载

        String url = file.public_url;

        getContext();
        DownloadManager manager = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
        Uri uri = Uri.parse(url);

        DownloadManager.Request request = new DownloadManager.Request(uri);

        request.setTitle(file.filename);
        request.setDescription(file.filename + " description.");
        request.allowScanningByMediaScanner();
        request.setAllowedOverRoaming(true);
        request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, file.filename + file.file_extension);

        manager.enqueue(request);

我已成功下载了此不使用DownloadManager的异步版本的映像

如果删除setAllowedNetworkTypes调用,该怎么办?@MateusGondim这并不能解决问题。