gpt4 book ai didi

android - 如何在android中使用shareIntent发送图像和文本

转载 作者:太空狗 更新时间:2023-10-29 13:14:46 27 4
gpt4 key购买 nike

我是分享 Intent 概念的新手,我想将我的应用程序中的图像和文本分享到其他应用程序,如 whatsapp 等。我试过了,但一个文本内容正在共享,我的要求是当我分享文本和图像时,它将与图像一起显示在 whats 应用程序中,请任何人帮助我如何得到这个

下面是我的代码

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,decsription_text.getText().toString()+imagelink);

shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Write the title what ever you want");
startActivity(Intent.createChooser(shareIntent, "Share Via..."));

我的图片从服务器这里获取图片 url

Picasso.with(getApplicationContext()).load((News_Updates.listData.get(pos)).getNewsImage()).into(Imageviewsample);

最佳答案

试试下面的代码

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"Here is my IMAGE");
startActivity(Intent.createChooser(shareIntent, "Share IMAGE Using..."));

这里我附上一张图片和文字。我将图像作为流发送。您可以临时保存图像并发送文件的 URI 作为额外的 Intent 。

关于android - 如何在android中使用shareIntent发送图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36099784/

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