Android Question how to catch a link to a PDF file

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi!
I have a special request: a person asks me to make an app that can intercept a click event with a link to a pdf file and use the value of the link to use for read data of a product.

I hope it's clear.

I understand that it is a strange request, but someone might have had the same request and found the solution.

thank you very much
rp
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi Erel,
pdf file is loaded into the device. So, it should be opened by the application and intercept the clicks and let the user do something to proceedings. In practice, the pdf file is a catalog and when the user clicks on the image should open a card product made with the app.
Thanks to the library pdfview I was able to open the file (although it is very slow), but was not able to handle events.

I hope I was clear.

Do you have any advice?

thanks

ps. this is the code that I used for open the file pdf.

Dim aIntent As Intent

Try
aIntent.Initialize(aIntent.ACTION_VIEW, "file:" & sPath & sFileName)
aIntent.SetType("application/pdf")

StartActivity(aIntent)

Catch
Msgbox(LastException.Message, "Errore durante l'apertura del file pdf")
End Try
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This line
aIntent.Initialize(aIntent.ACTION_VIEW, "file:" & sPath & sFileName)

should be
aIntent.Initialize(aIntent.ACTION_VIEW, "file://" & File.Combine(sPath, sFileName))

but in this way you enable the opening of the pdf file by any app to be able to read that file type.

To get what you would like, you should open the file within your app B4A.

I do not know how you could do it neither if you can do it.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi Lucas,
is just that: the file is opened by the app (with the library pdfView) and it works (slowly)
But is not generated or is not handled the event. if I open the same file with another program works on the link.

I hope I was clear.

thank you
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
After much research and testing I tried to use that library. also insert them my request.
thank you
 
Upvote 0
Top