How to make a generated pdf file on Android appear as a download?

Asked

Viewed 171 times

1

Well personal, I am developing an app and I Gero a PDF on Android at runtime. It turns out that the user does not receive any message, or anything, to know where the file is. I wonder if have how I send this file to the Android download manager, is there such possibility? If not, what is the best way to show the user where the file is being written? (It is being written in the application’s own folder)

  • As we do not know how you are doing this and difficult to answer.

  • Jaja will post the code @ramaral, I’m on mobile. But like this. In a simpler way to be explained: How to take a file that is already saved on the device and make it appear on as if it were being downloaded?

  • 1

    If the pdf is being generated in a service, create a notification. If it is being generated in the application the user is using, create a dialog to report where it was recorded.

  • I’ll test these solutions then, thanks!

  • @Joãoneto Take a look at the code of the author of this question: http://stackoverflow.com/questions/7908193/how-to-access-downloads-folder-in-android

1 answer

0


I decided as follows:

I created a download manager and added the file. Doing this it adds the downlaods folder and the download list, and also shows a notification.

File arquivo = getFile(fileName); // Meu método para pegar o arquivo.
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.addCompletedDownload(fileName, "Portal do Aluno Ufac: "+fileName, true, "application/pdf", arquivo.getAbsolutePath(), arquivo.length(), true);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.