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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With