android - 分享图片缩略图和标题中的文字,如 Instagram 分享到 WhatsApp Android
问题描述
我需要将内容分享到 whatsapp,就像 Instagram 在附图中所做的那样。
标题部分有图像和标题文本和链接的缩略图。然后消息部分有一个链接。
消息部分是直截了当的。任何有关实施标题部分的帮助都会有所帮助。
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TITLE, "title text");
sendIntent.putExtra(Intent.EXTRA_TEXT, "message section");
sendIntent.setType("text/plain");
startActivity(sendIntent);
我已经浏览了 whatsapp 常见问题解答,但他们没有提到从意图处理的标签列表。
解决方案
试试下面的代码
Uri imgUri = Uri.parse(pictureFile.getAbsolutePath());
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
intent.putExtra(Intent.EXTRA_STREAM, imgUri);
intent.setType("image/jpeg");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
activity.startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.MakeText(this,"Whatsapp not found",Toast.LENGTH_SHORT).show();
}
推荐阅读
- jprofiler - 如何在 JProfiler 中获取从一种方法传递到另一种方法的数据大小?
- javascript - 如何在three.js中的360全景图像中添加div元素或热点?
- azure - 使用 2 个 URL 公开相同的 Azure webapp,一个仅在公司网络内,一个公共
- javascript - 过滤数组并获取过滤数组的计数
- javascript - 单击按钮时如何卸载脚本?
- python - 如何总结熊猫数据框中每个第 x 列和第 x+2 列的列?
- java - ngnix 挂起请求:上游在从上游读取响应标头时未发送有效的 HTTP/1.0 标头
- c# - 以 0 或 1 为基础按下 Delete 按钮时隐藏行而不是删除
- y86 - CSAPP与pushtest结果混淆练习题4.7
- android - 如何用颤振解决代理设置问题?