Android Question How to open a remote pdf file by intent?

fash866

Member
Licensed User
Longtime User
my code is:
Dim itent As Intent
itent.Initialize(itent.ACTION_VIEW,"http://xxx.com/xxx.pdf")
itent.SetType("application/pdf")
StartActivity(itent)

When i this code, it's throw a exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://xxx.com/xxx.pdf typ=application/pdf flg=0x20000 }

What is the wrong?
 

DonManfred

Expert
Licensed User
Longtime User
i would guess there is no app installed which can open the pdf.

Maybe you can try the following

This works for me

B4X:
            Dim i As Intent
            i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal & "/", "filename.pdf"))
            i.SetComponent("android/com.android.internal.app.ResolverActivity")
            i.SetType("application/pdf")
            StartActivity(i)

But i have an app installed which can open pdfs
 
Upvote 0

ArminKH

Well-Known Member
i would guess there is no app installed which can open the pdf.

Maybe you can try the following

This works for me

B4X:
            Dim i As Intent
            i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal & "/", "filename.pdf"))
            i.SetComponent("android/com.android.internal.app.ResolverActivity")
            i.SetType("application/pdf")
            StartActivity(i)

But i have an app installed which can open pdfs
is this working with online pdf file?
 
Upvote 0
Top