Facebook的按钮在android中打开空白页 [英] Facebook like button opens blank page in android

查看:310
本文介绍了Facebook的按钮在android中打开空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我的Android应用程序在Facebook上喜欢一个url。我正在使用android webview来显示类似的按钮,但是当我点击它,没有任何反应,它显示一个空白的页面。但是当我使用相同的URL在Android网络浏览器的收益预期和喜欢的链接。



我使用以下代码

  WebView like_btn =(WebView)findViewById(R .id.WEBView); 
String url =http://www.facebook.com/plugins/like.php?layout=standard&show_faces=true&width=80&height=50&action=like&colorscheme=light&href= http://google.com;
like_btn.loadUrl(url);
like_btn.getSettings()。setJavaScriptEnabled(true);
like_btn.getSettings()。setAppCacheEnabled(true);
like_btn.getSettings()。setJavaScriptCanOpenWindowsAutomatically(true);

我正在做正确的事情,还是有其他方法来实现这个功能?
在SO上还有与此问题相关的其他问题,但他们只说明如何关闭空白页。真正的问题是它甚至不喜欢这个网址。

解决方案

问题在于Android中的webview并且浏览器不共享cookie,所以webview不知道用户的Facebook身份。在这里看到这个答案 Android WebView for Facebook Like按钮


I am trying to like a url on facebook through my android app. I am using android webview to show the like button but when i click it, nothing happens and it shows a blank page.But when i use the same url in the android web browser in proceeds as expected and likes the link.

I am using the following code

 WebView like_btn = (WebView) findViewById(R.id.WEBView);
 String url = "http://www.facebook.com/plugins/like.php?layout=standard&show_faces=true&width=80&height=50&action=like&colorscheme=light&href=http://google.com";
    like_btn.loadUrl(url);
    like_btn.getSettings().setJavaScriptEnabled(true);
    like_btn.getSettings().setAppCacheEnabled(true);
    like_btn.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

Am i doing it right or is there any other way to achieve this functionality? There are other questions related to this issue on SO but they only say how to close the blank page. The real issue is that it doesn't even 'like' the url.

解决方案

The problem is that in Android, the webview and the browser does not share cookies, so the webview does not know the Facebook identity of the user. See this answer here Android WebView for Facebook Like Button

这篇关于Facebook的按钮在android中打开空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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