在导航栏中分享一切正常,但在 Whatsapp 中它只显示 link 而不是文本

Share in Navigation bar all worked perfect but in Whatsapp it's only display link not text

在导航栏中分享一切正常,但在 WhatsApp 中它只显示 link 而不是文本。

所有其他应用程序都能完美运行电报、邮件等...但在 WhatsApp 中它只显示 link 而不是大写文本。

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

    }

在科特林中:

 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.

有效。