【问题标题】:how to send image along with text using shareIntent in android如何在android中使用shareIntent发送图像和文本
【发布时间】:2016-03-19 08:54:47
【问题描述】:

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

在我的代码下面

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..."));

我的图片是从服务器获取的图片地址

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

【问题讨论】:

标签: android android-sharing


【解决方案1】:

试试下面的代码

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 作为额外的意图发送。

【讨论】:

  • 我收到错误无法解析符号文件@Balu SKT
  • 您需要创建一个 File 对象。 (文件将是您要发送的图像)
  • 从服务器@Balu SKT 获取图像
  • 当我点击分享内容时,我为文件创建对象,我的 whatapp 中没有数据分享
  • 文件文件= getFileStreamPath("Imageviewsample");
猜你喜欢
  • 1970-01-01
  • 2019-06-10
  • 1970-01-01
  • 2014-07-03
  • 2011-12-10
  • 1970-01-01
  • 2015-11-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多