在不使用 Facebook sdk 的情况下通过 Facebook 上的 Intent 共享文本 [英] Share text via Intent on Facebook without using Facebook sdk

查看:37
本文介绍了在不使用 Facebook sdk 的情况下通过 Facebook 上的 Intent 共享文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 Facebook 不允许通过 Intent 共享文本,除非我们使用 Facebook sdk,因此我正在寻找一种方法来实现这一点.

我能想到 3 个我可以使用的黑客:

1) 由于 Facebook 允许图像共享,我可以生成一个 Bitmap 并在其上绘制共享文本并使用 Intent 共享图像.

2) Facebook 允许分享网址,分享时也会显示页面的Head.我可以在我的服务器上托管一个专用页面并将值作为 url 中的参数传递,并使用它生成 Head.(我没有使用 php 的经验,但我想这是可能的)

3) 将文本复制到剪贴板并通知用户.

使用所有 3 个的组合.

谁能给我推荐一种更好的方法来在不使用 Facebook sdk 的情况下在 Facebook 上分享我的内容?

提前致谢.

解决方案

您无法使用 android shareIntent 在 Facebook 中单独共享文本.

<块引用>

只能通过 Facebook SDK 使用共享链接功能.

如果有图片,Facebook 会简单地忽略来自意图的额外文本.您可以分享图片,但不允许分享文字内容.

不幸的是,Facebook 共享意图只能采用带有前缀 http://的单个 URL,并且没有额外的文本消息.实际上 facebook 去掉了文本内容,只允许 URL/Link.这是设计使然,我们无法控制它.

这会起作用

IntentsharingIntent = new Intent(android.content.Intent.ACTION_SEND);sharedIntent.setType("text/plain");sharedIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");startActivity(Intent.createChooser(sharingIntent, "Share via"));

这行不通.

IntentsharingIntent = new Intent(android.content.Intent.ACTION_SEND);sharedIntent.setType("text/plain");sharedIntent.putExtra(Intent.EXTRA_TEXT, "从应用程序共享文本");startActivity(Intent.createChooser(sharingIntent, "Share via"));

<块引用>

您可以在 Facebook 中共享文本的唯一方法是使用 FacebookSDK.

参考链接

Facebook 的 Android 共享意图-共享文本和链接

无法通过链接分享文本通过 Android Share Intent

Android 和 Facebook 分享意图

As Facebook doesn't allow sharing text via Intent unless we use Facebook sdk, I am looking for a way around to achieve this.

I can think of 3 hacks which I can use:

1) As Facebook allows image sharing, I can generate a Bitmap with sharing text drawn onto it and share the image using Intent.

2) Facebook allows sharing URLs, for which it also displays the Head of the page while sharing. I can host a dedicated page on my server and pass values as parameter in the url, and generate the Head using it.(I have no experience with php, but I guess this is possible)

3) Copy text to clipboard and notify user about this.

OR

Use combinations of all 3.

Can anyone suggest me a much better way around to share my content on Facebook without using Facebook sdk?

Thanks in advance.

解决方案

There is no way you can share Text alone in the Facebook using android shareIntent.

It is possible only through Facebook SDK using share links functions.

Facebook simply ignores the Extra Text from the intent if there is an image. You can share image, but it does not allow you to share the Text content.

Unfortunately the Facebook sharing intent can only take a single URL with prefixed http:// and no additional text message. Actually facebook strips out the text content and allows only URL/Link. It is by Design and we have no control over it.

This will work

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");
startActivity(Intent.createChooser(sharingIntent, "Share via"));

This will not work.

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Share Text from App");
startActivity(Intent.createChooser(sharingIntent, "Share via"));

Only approach you can share the text in the Facebook is using Facebook SDK.

Reference Links

Android share intent for facebook- share text AND link

Unable to share text with a link through Android Share Intent

Android and Facebook share intent

这篇关于在不使用 Facebook sdk 的情况下通过 Facebook 上的 Intent 共享文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆