derek
derek

Reputation: 25

DownLoad Manager is not public in android.app.downloadmanager. Cannot be accessed from outside package

I am getting an error "DownLoad Manager is not public in android.app.downloadmanager. Cannot be accessed from outside package" when I am trying to use DownLoadMaanger inside a setOnClickListener. Android Studio is not advising on what I can do to resolve the issue. Please can someone advise?

 DownloadManager.Request request = new  DownloadManager().Request(Uri.parse(pdfUrl));
            request.setDescription("pdf is downloading...");
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "thanh_pdf");

            DownloadManager downloadManager = (DownloadManager)getActivity()
                    .getSystemService(Context.DOWNLOAD_SERVICE);
            downloadManager.enqueue(request);   

Upvotes: 0

Views: 733

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Change:

new  DownloadManager().Request(Uri.parse(pdfUrl));

to:

new  DownloadManager.Request(Uri.parse(pdfUrl));

Upvotes: 2

Related Questions