Search code examples
androidandroid-download-manager

Download manager run in android 4 up to 6 but does not work?


I'm using download manager for developing an app. the point is download manager run in android 4 up to 6 but it does not download any file and it does not have any exception in during debug. in android 7 and after it works very well !!!

Uri Download_Uri = Uri.parse(Configuration.DWN_URL + item.getMediaPath());
                DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
                request.setTitle("Shiravy");
                request.setDescription(book.getTitle() + currentItem.getTitle());
                request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/Shiravy/" + book.getTitle() + currentItem.getTitle() + ".mp3");
                refId = downloadManager.enqueue(request);

Solution

  • it happened due to there was some space in my URL and when I uploaded file without any space in its name, it resolved.