【发布时间】:2018-02-11 21:33:39
【问题描述】:
我已经尝试了几个小时与Intent.ACTION_SEND 共享文本和图像(同时)。尽管我尽一切努力让它发挥作用,但我仍然无法做到。
我在 Google 上搜索过,这可能很奇怪,但我只找到了 2 篇关于如何同时分享文本和图像的帖子,我试过了,但没有一个他们工作了。我尝试使用一种方法,结果如下:
Uri imageToShare = Uri.parse("android.resource://com.example.application/drawable/invite"); //Image to be shared
String textToShare = "Text to be shared"; //Text to be shared
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, textToShare);
shareIntent.setType("*/*");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare);
startActivity(Intent.createChooser(shareIntent, "Share with"));
- 上面的代码显示错误消息“共享失败,请重试。”
- 我要发送的图像是
invite.png,它位于drawable文件夹中。 - 我使用的是 Android O (8.0) 手机。
我希望以上信息对您有用。我仍然是 Java 的初学者,任何帮助将不胜感激!
【问题讨论】:
标签: java android image text share