CustomWebView and attempt to open download

Hi, I am trying to create an application that allows to download a file and view / read / play it. In this example I try to open a downloaded pdf with a pdf file reader that I have on my device through ActivityStarter, but the idea is that it can work with an image, a video or audio file or any other file.
Currently, pdf files are downloaded to the device, but I cannot open them with the corresponding application.
The biggest problem is that I don't know the name of the file I'm going to download, so I can't use a specific path to that downloaded file or its location on the web page. So the idea is to open / read / view "the downloaded file". In this case, as it is a pdf, with a pdf file reader.
I attach the .aia file and an image of the blocks in case you could help me. I also add some unsuccessful attempts.




Bug noted.

On the blocks? Can you point me where? Thanks.
By the way, this is the response that the application (compiled, installed and with permissions given manually) gives me after downloading a pdf file:

Explanation: Starting from Android 10, the extension downloads files in ASD, so it is not possible for other apps to open/view files downloaded there.
It can be fixed, but then user will have to provide an URI instead of file path, which opens up possibilities of downloading files even in SD Card with the help of SAF.

This is working:

v12 beta aix:
com.sunny.CustomWebView.aix (71.2 KB)

downloadDir must be an empty string.

Do I add your FileTools extension?

Obviously, you should.

Hello Sunny, first of all sorry for the delay in answering. I tried your suggestion but it didn't work and did other tests. I am attaching screenshots and a brief explanation of each one.
(In all cases, it was tested with compilation (APK) and with the storage and access permissions to the SD card given manually)
1- In this case, the pdf file was downloaded but not opened.

2- In this case the pdf file was downloaded but not opened.

3- In this case, the file was downloaded and then the mobile asked me what application I wanted to use to open it and I selected Acrobat Reader. But then it gave me the error message "Cannot display PDF (cannot open SMCOVID-19-4.pdf)"

4- In this case, the file was downloaded and then the mobile opened Acrobat Reader, but then it gave me the error message "This file could not be accessed; check the connection or reduce the file name".

The pdf files are not corrupt. They can be read in Acrobat Reader if opened from the file explorer.
Could you give me some idea how to fix the problem?

Please post an apk of this.

1 Like

Sorry, I only can upload the aia file.
Download_and_Read_PDF.aia (102.2 KB)
I add a link to the apk:

Hi @Toni and @vknow360 Sunny, I have finally gotten the application to work, inspired by Toni blocks.
Sunny's Customwebview and FileTools extensions should be used (thanks again for your great work).
The storage permissions must be given manually (at least in my example, since at the moment I have not managed to give them automatically (but that is another battle :slight_smile: )).
The application works both by giving instructions to open a specific application (Acrobat Reader in my case, using class and package), as well as by letting the application ask us with which application to open it (such as, for example, Drive's PDF Reader ).
I attach an image of the blocks and the aia so that you can test the application, and the extensions.
Thank you very much to both!

Custom Webview Extension by @vknow360
FileTools Extension by @vknow360
Download_and_Read_PDF.aia (102.4 KB)


A minor mistake which we couldn't notice somehow but finally it got caught :grinning:
DataUri asks you to provide an uri and all I could tell was to pass path instead. :pensive:
Glad you solved the problem! :slightly_smiling_face:

Sometimes something simple can delay a project, but as we say in my country, "All is well that ends well" :slight_smile:
Thank you very much for your help and your extensions. Without you it would not have been possible.

@Clipper I replaced the uploaded extensions by a link to the extensions...
only extension authors are allowed to upload the extension itself...
thank you



I'm sorry, I did not know, I will not make the mistake again. Thanks for the info.

Thank you @Clipper for the solution you share. I have tried it and it works!
but in my case I need to open pdfs that are in the internal storage of the mobile.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.