如何通过单击按钮打开Whatsapp组? [英] How to open Whatsapp group by clicking a button?

查看:79
本文介绍了如何通过单击按钮打开Whatsapp组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个简单的电话目录,并且可以通过单击按钮来打开Whatsapp联系人.

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

这是示例代码:

Intent intentWhatsapp = new Intent("android.intent.action.MAIN");
intentWhatsapp.setAction(Intent.ACTION_VIEW);
String url = "https://api.whatsapp.com/send?phone=" + "90xxxxxxxx";
intentWhatsapp.setData(Uri.parse(url));
intentWhatsapp.setPackage("com.whatsapp");
startActivity(intentWhatsapp);}

如何通过单击android中的按钮来打开Whatsapp组?

How can I open the Whatsapp group by clicking a button in android?

希望给我任何建议!

推荐答案

您必须使用组链接.用户安装您的应用程序时,应要求他们复制whatsapp组信息中的组链接,然后将其存储以直接从您的应用程序访问该组.该链接仅对群组管理员可见,因此,如果用户不是管理员,则应指示他们向管理员询问链接.尽管whatsapp打算使用此链接来邀请组,但它可以完成所需的组聊天的工作.

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);

这篇关于如何通过单击按钮打开Whatsapp组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆