java - 标题和正文 - android 应用程序中的意图 Action_SEND
问题描述
所以,我试图通过 Viber、Whatsapp 等社交应用程序分享我文章的标题和文本。所以,下面是我的代码,问题是它只共享正文,而不是标题。但它会读取它,正如您在共享对话框中看到的那样(它是具有较大字体的文本)。但正如您在第二张截图中看到的那样,它只传递了正文。这里有什么问题?
http://prntscr.com/urd4z6 http://prntscr.com/urd57q
holder.imgShareM.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String s1 = holder.txt_short_desc.getText().toString();
String s2 = holder.txt_description.getText().toString();
Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TITLE, s1);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, s2);
activity.startActivity(Intent.createChooser(sharingIntent, "Share the article via:"));
}
});
编辑:一点更新。我尝试通过以下方式在底部添加我的应用程序链接:
sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.sharing_text) + "\n" +
"https://play.google.com/store/apps/details?id=" + getPackageName());
现在它只发送那个。所以,它似乎只发送最后一件事。
解决方案
您应该使用此行将标题添加到您的电子邮件:
intent.putExtra(Intent.EXTRA_SUBJECT, "Your Subject Here");
推荐阅读
- java - 即使 sql 查询不应该返回任何记录,JUnit 测试仍然通过
- arcore - Arcore:如何获得放置在表面上的图像的尺寸?
- python - DLIB:ImportError:/usr/local/cuda/lib64/libcudnn.so.7:文件太短
- ssl - SSL Labs:错误的顺序,额外的证书
- mysql - MySQL 查询需要更多时间来获取数据 [MySQL]
- delphi - Delphi 发送带有 TIdHttp 和特殊字符的 POST
- kubernetes - 可以在 GKE 上使用 Google Cloud IAM 设置命名空间级别权限吗?
- android - 无法使用 ScrollView 滚动线性布局
- javascript - Javascript 中的原始数据与复杂数据
- reactjs - 状态不同步