Android Question share PDF file

Kiran Raotole

Active Member
Licensed User
I have this code its open PDF file
B4X:
    Dim in As Intent
    in.Initialize(in.ACTION_VIEW,f1.CreateFileProviderUri(Starter.shared,"1.pdf"))
    in.Flags=1
    StartActivity(in)

I have to share PDF file
I try like this
B4X:
    in.Initialize(in.ACTION_SEND,f1.CreateFileProviderUri(Starter.shared,"1.pdf"))
    in.SetType("application/pdf")
    'in.Flags=1
    in.Flags=1
    StartActivity(in)

Buts open app selection, I select Whatsapp app and select contant, But then its close WhatsApp
Whats a Problem?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

asales

Expert
Licensed User
Longtime User
My code (works fine to share with WhatsApp):
B4X:
Sub Button2_Click
    If Not (File.Exists(Starter.shared,"1.pdf")) Then
        File.Copy(File.DirAssets,"1.pdf",Starter.shared,"1.pdf")
    End If

    Dim in As Intent
    in.Initialize(in.ACTION_SEND,"")
    in.SetType("application/pdf")
    in.SetComponent("")
    in.PutExtra("android.intent.extra.STREAM", CreateFileProviderUri(Starter.shared,"1.pdf"))

    in.Flags=1
    StartActivity(in)
End Sub
 
Upvote 0
Top