gpt4 book ai didi

android - 通过 Twitter 应用程序从 URL 分享图像 - Android

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

我正在尝试通过 Twitter 应用分享一些文本和图像。图片来源是一个网址。下面是我的代码:

sharingIntent = new Intent(android.content.Intent.ACTION_SEND);    
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url+"");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("http://example.com/images/thumbs/file_name.jpg"));

但只有文本通过 Twitter 应用程序共享。我还收到一条消息说“无法加载图片”。这段代码有什么问题?

最佳答案

Sourav,我认为您必须先下载图片,然后才能分享。你可以做到manually ,或者您可以使用像 this 这样的库.您可以在库的存储库中找到有关如何设置和使用它的简单文档。

下载图片后,您可以按照以下方法操作:

private Intent shareIntent(String bookmark_url, String imagePath){
sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
return sharingIntent;
}

如果只是想模拟“Parsing image on the fly”,分享后删除。

希望对你有帮助!

关于android - 通过 Twitter 应用程序从 URL 分享图像 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24436501/

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