How to open Whatsapp group by clicking a button?

前端 未结 1 1571
感情败类
感情败类 2021-01-21 23:45

I made a simple phone directory and was able to open the Whatsapp contacts by clicking a button.

Here is the sample code:

Intent intentWhatsapp = new Int         


        
相关标签:
1条回答
  • 2021-01-21 23:59

    You have to use group link. When the user install your app, you should ask them to copy the group link from the whatsapp group info, then you store it to access that group directly from your app. This link is only visible by groups admins, so if the user isn't admin, you should instruct them to ask the link from the admin. Although this link was intended by whatsapp for invitation to groups, it makes the job of opening the desired group chat.

    Intent intentWhatsapp = new Intent(Intent.ACTION_VIEW);
    String url = "https://chat.whatsapp.com/<group_link>";
    intentWhatsapp.setData(Uri.parse(url));
    intentWhatsapp.setPackage("com.whatsapp");
    startActivity(intentWhatsapp);
    
    0 讨论(0)
提交回复
热议问题