Android Question Send Message to WhatsApp Group

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello All, I red about a similar project here in the Forum, but as the last post was from 2017, I decided to post new one.

Is it possible to send a Text message to a specific WhatsApp groug ?
This is for Civil Proteccion and disaster managment purposes.

Regards
 

moster67

Expert
Licensed User
Longtime User
Yes, it is. You need a group id to be able to do that. If you created the group then you have it, otherwise you need to ask the administrator. If you need further information let me know
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
You need to use an intent. I am not home now but I will post it later
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
If I recall correctly it might be present in the sample project I posted some time ago in regard to Accessibility services. Search for accessibility services here in the forum and you should find it
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Yes, the code required was included in the sample project I posted in the Accessibility Services thread.

Anyway, here it is:

B4X:
Dim link As String = "xxxxxxxxxxxxxxxxxxxxxx"  'insert group link. Can only be seen in WhatsApp by user who created the group
        Dim Url As String = "https://chat.whatsapp.com/" & link

        Dim Intent1 As Intent
        Dim pm As PackageManager
        Intent1 = pm.GetApplicationIntent("com.whatsapp")
        If Intent1.IsInitialized Then
            'Se WhatsApp è installato
            Dim Intent2 As Intent
            Intent2.Initialize(Intent2.ACTION_VIEW, Url)
            StartActivity(Intent2)
        Else
            ToastMessageShow("WhatsApp is not installed", True)
            Return
        End If
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

moster67

Expert
Licensed User
Longtime User
On second thoughts, I was perhaps too fast in replying. Groups are a bit special.
The code I posted will open the WhatsApp group, then you need to use the accessibility services to fill in the message and to trigger the send-button.
It should be quite trivial to implement. Just look at the sample project I posted in the other thread.
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
On second thoughts, I was perhaps too fast in replying. Groups are a bit special.
The code I posted will open the WhatsApp group, then you need to use the accessibility services to fill in the message and to trigger the send-button.
It should be quite trivial to implement. Just look at the sample project I posted in the other thread.

Yes, because I have tried several combinations with the send and &text= and nothing works.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Modify the sample project using accessibility services according to your needs and it will work....
I did some tests myself when I wrote the library and it worked fine.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
It might work with earlier versions although you may need to adapt the B4A-code a little bit.
If I recall correctly, there is nothing in particular in the java-library, which is the base to get things working, which would prevent you from not using an older version of B4A.
 
Upvote 0
Top