问题
I am using the code shown below for like a url in facebook:
String htmlCodeGoesHere="<div id=\"fb-root\"></div>"+
"<script>(function(d, s, id) {"+
" var js, fjs = d.getElementsByTagName(s)[0];"+
" if (d.getElementById(id)) {return;}"+
" js = d.createElement(s); js.id = id;"+
" js.src = \"http://connect.facebook.net/en_US/all.js#xfbml=1& appId="+APP_ID+"\";"+
" fjs.parentNode.insertBefore(js, fjs);"+
"}(document, 'script', 'facebook-jssdk'));</script>"+
"<div class=\"fb-like\" data-href=\" http://www.facebook.com/ToshibaInnovation\" data-send=\"false\" data-width=\"450\" data-show-faces=\"true\"> </div>";
webviewliketoshiba.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webviewliketoshiba.setBackgroundColor(Color.WHITE);
webviewliketoshiba.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) {
Log.e("js ", message);
return false;
}
});
webviewliketoshiba.loadDataWithBaseURL(null, htmlCodeGoesHere, "text/html", "UTF_8", null);
This is showing like button in a web view. I am using OnTouchListener for web view to take particular actions after like. But click on like button it opens browser window with no contents. And not able to get response for like a page.
Can anyone help me to do like functionality. I need response for like a facebook page. I have a valid facebook session and tocken. by getting positive responce from like a url, i can control my other codes.
回答1:
If you are developing your application on core android part, I would suggest you to use the facebook-android-sdk. See the below link :
https://github.com/facebook/facebook-android-sdk
You can find its tutorial at http://ericosgood.com/prog/facebook-android-sdk-tutorial/
Regards.
来源:https://stackoverflow.com/questions/8454659/facebook-like-in-android