Android Question How to open Adobe Acrobat Reader with the correct pdf file immediately?

welu1805

Active Member
Licensed User
Longtime User
Dear all,

in my app I create a PDF file with PdfDocument. I want to see it in Adobe Acrobat Reader.

With this code I can start Adobe Acrobat Reader:

B4X: Copy
    Dim in As Intent
    in = pm.GetApplicationIntent("com.adobe.reader")
    StartActivity(in)

How can I give the filename to the reader to open the correct pdf immediately?

Thanks for your help
Lutz
 
Note that you need to use FileProvider on higher Android versions and especially higher tagetSDK
This works with targetsdk 28

B4X: Copy
Dim FileName As String = "xx.pdf"
        File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
        Dim in As Intent
        in.Initialize(in.ACTION_VIEW, "")
        Starter.Provider.SetFileUriAsIntentData(in, FileName)
        'Type must be set after calling SetFileUriAsIntentData
        in.SetComponent("android/com.android.internal.app.ResolverActivity")
        in.SetType("application/pdf")
        StartActivity(in)
Hope it helps

References:
android.jar / targetSdkVersion / minSdkVersion
FileProvider
 
Upvote 0
Thanks, it works. But I get some apps to choose: Adobe Acrobat, WPS Office, PDF Capture ...

Is it possible to get ONLY Adobe Acrobat without choosing?
 
Upvote 0
Sorry, but it doesn't work. There are many apps again to choose one.

This example works:
B4X: Copy
    Dim ph As Phone
    Dim pm As PackageManager
    Dim in As Intent
    in = pm.GetApplicationIntent("com.adobe.reader")
    
    If in.IsInitialized Then
        Msgbox("found","")
        
        Dim FileName As String = "xx.pdf"
        File.Copy(File.DirDefaultExternal & "/Examples", FileName, Starter.Provider.SharedFolder, FileName)
        Starter.Provider.SetFileUriAsIntentData(in, FileName)
        StartActivity(in)
    End If

How can I close Acrobat Reader when the app is finished?
 
Upvote 0
Back
Top