Android Question Open PDF

Indy

Active Member
Licensed User
Hi

I have read many post regarding this subject and to be honest I still haven't worked out how to do this. So I thought I'd post what I have currently and hopefully get some guidance. The code I have is as follows;

B4X:
Dim ia As Intent
ia.Initialize(ia.ACTION_VIEW,File.Combine(File.DirAssets,"UG.pdf"))
ia.SetType("application/pdf")
StartActivity(ia)

This clearly does not work but, it doesn't crash either. I already have Adobe PDF Reader installed and know that PDF files open just fine if I launch them from any file manager. What I'd like to do is open a mini user guide for my app from within itself. I have placed a button on the screen which activates the "click" event and executes the above code. As I mentioned, the app doesn't crash but, I do get a message saying something along the lines the file could not be accessed. I do briefly see a glimsp of the Adobe Reader logo flash up before disapperaring.

Could somebody point me in the direction of what else I need to do to get this to work? I don't need any of the advance features like creating or sharing between other apps, just want to open the file for viewing.

Thanks
 

DonManfred

Expert
Licensed User
Use FileProvider to share a file to another app.
 
Upvote 0
Top