Skip to content Skip to sidebar Skip to footer

How To Use Download Manager With Storage Access Framework / Mediastore

I need to download a pdf file and then fire an intent so that other suitable app can show the file. Till now, I was using setDestinationInExternalPublicDir of DownloadManager to se

Solution 1:

Then I used getExternalStoragePublicDirectory to create the file and get the uri through FileProvider and ultimately fired the intent with ACTION_VIEW.

No. That is not the way to go.

Instead you should register a broadcast receiver for ACTION_DOWNLOAD_COMPLETE.

In onReceive() you can obtain an uri for the downloaded file.

Use that uri with a grant read permission flag for your intent ACTION_VIEW.

Post a Comment for "How To Use Download Manager With Storage Access Framework / Mediastore"