gpt4 book ai didi

java - 在导航栏中分享一切都很完美,但在 Whatsapp 中它只显示链接而不是文本

转载 作者:行者123 更新时间:2023-12-02 10:40:14 25 4
gpt4 key购买 nike

在导航栏中分享一切都很完美,但在 WhatsApp 中它只显示链接而不是文本。

所有其他应用程序都可以完美运行电报、邮件等...但在 WhatsApp 中,它仅显示链接而不是上部文本。

try {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
final String appPackageName = getApplicationContext().getPackageName();
String strAppLink = "https://play.google.com/store/apps/details?id=" + appPackageName;
shareIntent.setType("text/plain");
String shareBody = strAppLink;
String shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n";
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(shareIntent, "Share using"));
}
catch (ActivityNotFoundException e)
{

}

最佳答案

试试这个

在java中:

try {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
final String appPackageName = getApplicationContext().getPackageName();
String strAppLink = "https://play.google.com/store/apps/details?id=" + appPackageName;
shareIntent.setType("text/plain");
String shareBody = strAppLink;
String shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n";
String data = shareSub + shareBody
// shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data);
startActivity(Intent.createChooser(shareIntent, "Share using"));
} catch (ActivityNotFoundException e) {

}

在 Kotlin 中:

 try {
val shareIntent = Intent(android.content.Intent.ACTION_SEND)
val appPackageName = applicationContext.packageName
val strAppLink = "https://play.google.com/store/apps/details?id=$appPackageName"
shareIntent.type = "text/plain"
val shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n"
val data = shareSub + strAppLink
//shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub)
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data)
startActivity(Intent.createChooser(shareIntent, "Share using"))
} catch (e: ActivityNotFoundException) {

}

只需进行一项更改,即注释设置主题的行。将主题文本与文本合并,并在 android.content.Intent.EXTRA_TEXT 中设置合并的文本。

它有效。

关于java - 在导航栏中分享一切都很完美,但在 Whatsapp 中它只显示链接而不是文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52967563/

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