gpt4 book ai didi

android - 如何在 Whatsapp 中将文本设置为描述(关于)?

转载 作者:行者123 更新时间:2023-11-29 23:55:22 27 4
gpt4 key购买 nike

我想在 Whatsapp 中将文本设置为描述或您的状态,如“可用”。我使用 Intent 但如果我想通过故事分享此文本或将其发送给某人,它会在 Whatsapp 中打开一个选择页面。那是因为 ACTION_SEND。是否有某种类型的操作或任何解决方案可以解决我的问题?

这是我的代码

Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");

最佳答案

根据 WhatsApp FAQ

There are two ways to integrate with WhatsApp:

-Through a custom URL scheme

-Through Android's intent system.

自定义 URL 方案

If you want to open a WhatsApp chat with a pre-filled message, you can use our custom URL scheme to do so. Opening whatsapp://send?text= followed by the text to send, will open WhatsApp, allow the user to choose a contact, and pre-fill the input field with the specified text.

例子

https://api.whatsapp.com/send?phone=15551234567&text=I%27m%20interested%20in%20your%20car%20for%20sale

Android Intent 系统

Like most social apps on Android, WhatsApp listens to intents to share media and text. Simply create an intent to share text, for example, and WhatsApp will be displayed by the system picker:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setPackage("com.whatsapp");
sendIntent.setType("text/plain");
startActivity(sendIntent);

使用此代码,您可以打开与给定号码的 whatsapp 聊天。

 void openWhatsappContact(String number) {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));
}

您不能以编程方式设置用户状态。

您还可以查看这些以获取更多详细信息:

  1. One
  2. Two

关于android - 如何在 Whatsapp 中将文本设置为描述(关于)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50434800/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com