EastBK
EastBK

Reputation: 411

Facebook comment box in Android

In my app, I would like to show comments in my website by webview. This is what I have done:

In assets folder I have got a file named comment.html

<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<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=467390796664437";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://www.haivl.com/photo/1259735" data-width="470"></div>
</body>
</html>

The activity displays as follow: enter image description here

As you can see, the facebook comment box obscured and I can't see whole comments. Anyone has a idea?

Thanks for your attention!

Upvotes: 0

Views: 3366

Answers (1)

Krit
Krit

Reputation: 620

base on this post Failed to render Facebook comments on Android WebView via local HTML?

You need to specify a base URL.

myWebView.loadDataWithBaseURL("http://www.haivl.com", 
"<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<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=467390796664437";
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://www.haivl.com/photo/1259735" data-width="470"></div> 
</body>
</html>", "text/html", null, null);

Upvotes: 1

Related Questions