Android 应用程序中的 Facebook Like 按钮?
还有其他一些老问题提出了类似的问题,但似乎没有任何明确的答案。自从提出这些问题以来已经过去了一段时间,所以我想知道是否有办法做到这一点?
查看 Facebook 的 Android SDK,这里有一些关于如何在墙上分享内容的示例,请发布图片到你的墙上,登录,注销等...但似乎没有任何关于添加一个简单的“喜欢”按钮...我希望能够向我的应用程序添加一个“喜欢”按钮(通过 ImageView或者可能是一个样式化的按钮),一旦点击 Facebook 就会加载授权登录对话框,然后请求您的许可来喜欢该应用程序。
好像他们那里会有什么东西……我只是没有看到它吗?
有些人建议制作一个与 HTML Facebook Like 按钮大小相同的小型 WebView,并将其集成到您的布局中。这样做的问题是,当用户单击 WebView 中的 Like 按钮时,它会想要打开一个 Javascript 窗口供用户登录 Facebook,但这个对话框几乎肯定不适合微小的 WebView。
是否有任何明确的方法可以在 Android 应用程序中添加 Facebook Like 按钮?
There are a few other old SO questions asking a similar question, but there doesn't seem to be any definitive answer for them. Some time has passed since those questions were asked, so I was wondering if there was a way to do this yet?
Looking at Facebook's Android SDK, there are examples on how to share things on your wall, post pictures to your wall, login, logout, etc... but it there doesn't appear to be anything about adding a simple Like button... I was expecting to be able to add a Like Button to my app (via a ImageView or maybe a styled Button), once clicked Facebook would load an authorization login dialog and then ask for your permission to Like the app.
It seems like something they would have in there... am I just not seeing it?
Some people have suggested making a tiny WebView that is the size of the HTML Facebook Like button and integrating it into your layout. The problem with this, is that when the user clicks the Like button in the WebView, it will want to open a Javascript window for the user to login to Facebook, but this dialog will almost definitely not fit in the tiny WebView.
Are there any definitive approaches to adding a FaceBook Like button in an Android App?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我一周前就试过了。有一个“/like”图形方法,它会返回错误,因为不可能喜欢 SDK 中的某些内容。所以你别无选择,只能启动网站。
Well, I tried that a week ago. There is a "/like" graph method, which returns an error since it is not possible to like something from the SDK. So you have no choice but launching the website.
“赞”按钮可用于赞 Facebook 页面或任何开放图谱对象,并且可以通过 URL 或 ID 引用。代码如下所示。
文档 android facebook sdk
在 Activity 或 Fragment 的 onCreate 方法中,使用 UiLifecycleHelper 或调用 Settings.sdkInitialize:
然后设置 Like 按钮的对象 ID(可以是 URL 或 Facebook ID):
最后,在 onActivityResult 方法中再次调用 UiLifecycleHelper
< img src="https://i.sstatic.net/y9KMs.png" alt="在此处输入图像描述">
The Like button can be used to like a Facebook Page or any Open Graph object and can be referenced by URL or ID. Here's what the code looks like.
documentation android facebook sdk
In your Activity or Fragment's onCreate method, use either the UiLifecycleHelper or call Settings.sdkInitialize:
Then set the object ID for the Like button (this can be a URL or a Facebook ID):
Lastly, call the UiLifecycleHelper again in your onActivityResult method