Download manager does not recognize .mp3 files

I am using a download manager and I want to download some audio files using my own webview.

I am using the following code:

        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url2));
        request.setDescription("Downloading");
        request.setTitle("File :");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        }
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "audio.mp3");
        DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        manager.enqueue(request);

      

Even if the filename is audio.mp3 download manager, it doesn't return the file type. ScreenShot explains the main problem.

enter image description here

Using other apps like the default browser downloaded files looks like this! enter image description here

+3


source to share


1 answer


The solution is simple: Just add the following line

request.setMimeType("audio/MP3");

      



More details here

+5


source







All Articles