Android Question Intent & Whatsapp

luke2012

Well-Known Member
Licensed User
Longtime User
How to send intent directly to Whatsapp ?

I'm trying to write the code :

B4X:
    Dim i As Intent
    i.Initialize(i.ACTION_SEND, "file://" & File.DirRootExternal & "/pic.png")
    i.SetType("image/png")
    i.SetComponent("com.whatsapp")
    i.WrapAsIntentChooser("Share pic...")
    StartActivity(i)
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the correct code:
B4X:
Dim i As Intent
i.Initialize(i.ACTION_SEND, "file://" & File.DirRootExternal & "/1.jpg")
i.SetType("image/png")
Dim jo As JavaObject = i
jo.RunMethod("setPackage", Array As Object("com.whatsapp"))
StartActivity(i)
However it doesn't seem to work.
 
Upvote 0

luke2012

Well-Known Member
Licensed User
Longtime User
This is the correct code:
B4X:
Dim i As Intent
i.Initialize(i.ACTION_SEND, "file://" & File.DirRootExternal & "/1.jpg")
i.SetType("image/png")
Dim jo As JavaObject = i
jo.RunMethod("setPackage", Array As Object("com.whatsapp"))
StartActivity(i)
However it doesn't seem to work.

I agree @Erel.
I discovered that if you put "com.whatsapp/.Main" as component to interact, the chooser will not display and the intent open whatsapp directly.
The problem is that a blank message appear without the image expected.
 
Upvote 0
Top