Android Question WhatsApp Intent

jazzzzzzz

Active Member
Licensed User
Longtime User
I have found this intent to share image with caption to whatsapp,Its working well in Android studio ,Could some one convert it to B4A...?

B4X:
Uri uri = Uri.parse("/storage/emulated/0/a.jpg");

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "whatsAppMessage");
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_STREAM,uri);
        intent.setType("image/jpeg");
        intent.setPackage("com.whatsapp");
        startActivity(intent);
 
Last edited:

jazzzzzzz

Active Member
Licensed User
Longtime User
never mind after looking into some samples I figured it out

If Any one want to share image with text in whatsapp they can use this....;)

B4X:
    Dim i As Intent
    i.Initialize(i.ACTION_SEND, "")
    i.PutExtra("android.intent.extra.TEXT", "This is the text")
    i.SetType("text/plain")
    Dim u As Uri
    u.Parse("file://" & File.Combine(File.DirRootExternal, "a.jpg")) '<-- change to a valid image file
    i.PutExtra("android.intent.extra.STREAM", u)
    i.SetType("image/jpeg")
    Dim jo As JavaObject = i
    jo.RunMethod("setPackage", Array("com.whatsapp"))
    StartActivity(i)
 
Upvote 0
Top