首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过图片和文本获取共享数据

通过图片和文本获取共享数据
EN

Stack Overflow用户
提问于 2016-11-18 21:27:02
回答 2查看 151关注 0票数 0

我想在我的应用程序中以同样的WhatsApp方式共享数据:

当我在我自己的应用程序中尝试它时,我只能得到文本("Check out...")。如何获取其余的数据:图片、标题、描述和网站地址?

代码语言:javascript
复制
 Intent intent = getIntent();
 String action = intent.getAction();
 String type = intent.getType();
 if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        } else if (type.startsWith("image/")) {
            handleSendImage(intent); // Handle single image being sent
        }
 } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            handleSendMultipleImages(intent);
        }
 }

我只有在EXTRA_TEXT中才能得到ACTION_SEND。

EN

回答 2

Stack Overflow用户

发布于 2016-11-18 21:38:27

您可以通过流式传输图像来共享图像。但这主要取决于您选择共享的应用程序是否支持图像流共享。

代码语言:javascript
复制
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile));
startActivity(Intent.createChooser(shareIntent, "Share image using"));

点击此链接,了解有关共享选项的信息。

https://guides.codepath.com/android/Sharing-Content-with-Intents

要从其他应用程序接收共享数据,请选中此链接:

https://developer.android.com/training/sharing/receive.html

票数 0
EN

Stack Overflow用户

发布于 2017-01-04 11:56:03

我在最后这样做的方式是在后端解析链接元数据标签,并将详细信息发送到应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40678304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档