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

标签 android android-sharing

我是分享 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/

相关文章:

Android Google Play 如何获得更长的堆栈跟踪?

android - flipkart 等应用程序和其他应用程序如何检查设备中安装的应用程序

iphone - 音乐网站 : how to make it work on android/blackberry/iphone/symbian?

android - 即使文件大小非常小,也会出现 TransactionTooLargeException

java - 当我在另一个应用程序 Intent 上调用 startIntent 时抛出 SecurityException

android - 如何将多张图片分享到 whatsapp 应用程序?

java - 在 Activity 之间传递解析 GeoPoint

android - 通过 NDK 在 Android 中使用 C 库

android - 分享 Intent 不适用于 Facebook Messenger

android - 如何在 android 中共享 *.txt 文件