I successfully download a pdf file from the internet and then I open the downloads folder using the following Intent:
Intent pdfFileIntent = new Intent();
pdfFileIntent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
ctx.startActivity(pdfFileIntent);
This code is located within the onReceive() method of a BroadcastReceiver I created to deal with download complete events. The download is complete and successful (I can see the download status in the downloads folder, which is opened right after the download is complete, as expected). However, when I click the newly downloaded file, another dialog pops up which requests me to select the application with which the file will be opened (I can select either Adobe Reader or Quickoffice). When I select Adobe Reader, I get the error : "The document path is not valid" and when I select Quickoffice, I get the error: "File cannot be opened".
This is terribly annoying especially because the downloads folder and the download process and management of downloaded files is completely out of my hands - Android is aware of the files in the downloads directory when it presents them to me, so how can it be that it doesn't pass a valid path? What is going on? To make things clear, I didn't specify any path in my code - Android chose the path in which to save the file. And I can even see that the file has a reasonable size in KBs, which means it's not empty and it's definitely a pdf file (.pdf extension).
Please help. Thanks in advance.
Sometimes, corrupted system files or bad sectors on Windows system drive may cause hard drives, folders, or files inaccessible. Therefore, fixing corrupted system files and repair bad sectors on the hard drive may help you fix the Downloads folder that won't open error.
Clear the Play Store's cache and data Clearing the app store's cache and data might fix the problem. Most people don't clear the Play Store's cache and data regularly, but it's worth a shot if you're having trouble getting apps to download on your device.
And I can even see that the file has a reasonable size in KBs, which means it's not empty and it's definitely a pdf file (.pdf extension).
The fact that a file has the PDF extension doesn't necessarily make it a valid PDF file! Move the file to your PC and see whether you can open it there. You may have a bug in the code performing the download, causing some invalid content to be written to the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With