Facebook的按钮在android中打开空白页 [英] Facebook like button opens blank page in 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屋!