我制作了一个简单的电话目录,并能够通过单击按钮来打开Whatsapp联系人。
这是示例代码:
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组?
希望给我任何建议!
最佳答案
您必须使用群组链接。
当用户安装您的应用程序时,您应该要求他们复制whatsapp组信息中的组链接,然后将其存储以直接从您的应用程序访问该组。
该链接仅对网上论坛管理员可见,因此,如果用户不是管理员,则应指示他们向管理员询问链接。
尽管whatsapp打算使用此链接来邀请组,但它可以打开所需的组聊天。
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);