Sou*_*rav 7 twitter android uri android-intent android-sharing
我试图通过Twitter应用程序分享一些文本和图像.图像源是web url.以下是我的代码:
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"));
Run Code Online (Sandbox Code Playgroud)
但只有文本通过Twitter应用程序共享.我还收到一条消息" 无法加载图片 ".这段代码有什么问题?
小智 7
Sourav,我认为你必须在分享之前下载图片.你可以手动完成,也可以像这样使用库.您可以在库的存储库中找到有关如何设置和使用它的简单文档.
下载完图片后,您可以按照以下方法操作:
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;
}
Run Code Online (Sandbox Code Playgroud)
如果您只是想模拟"动态解析图像",请在共享后将其删除.
希望这对你有所帮助!
| 归档时间: |
|
| 查看次数: |
6094 次 |
| 最近记录: |