gpt4 book ai didi

android - 如何在 android 中使用 Share Intent 分享图片+文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:18:30 24 4
gpt4 key购买 nike

我使用此代码,但它无法正常工作。

String Body = "Deals Name: " + Bussinessname + "\n"
+ "Deals: " + deal + "\n" + "Address: " + city
+ " ," + country;

Intent share = new Intent(android.content.Intent.ACTION_SEND);

Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + image);
share.setType("image/*");
share.putExtra(Intent.EXTRA_SUBJECT, "The EssexPass");
share.putExtra(Intent.EXTRA_TEXT, Body);
share.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(share, "Share Deal"));

当我使用文本类型时,它可以正常工作。
但我想分享一段文字和一张图片。
并且共享 Intent 在 FaceBook 中不起作用。

最佳答案

试试下面的代码:

String fileName = "image-3116.jpg";//Name of an image
String externalStorageDirectory = Environment.getExternalStorageDirectory().toString();
String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images
Uri uri = Uri.parse("file:///" + myDir + fileName);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/html");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test Mail");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Launcher");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share Deal"));

关于android - 如何在 android 中使用 Share Intent 分享图片+文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29911053/

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