In the HTML file, I used the Facebook Social Comment plugin and it works fine, but when I tried to display the same file in android using webview, then it displays only comments and not the comments field, and it displays the "Login to facebook to post a comment" button " When I tried to login by clicking on this button, instead of showing a comment box; the page is redirected to the facebook profile. Please, help...
Here is the code:
HTML code:
<head> <meta content='website' property='og:type'/> <meta content='http://graph.facebook.com/username' property='fb:admins'/> <meta content='http://example.com/test.html' property='og:site_name'/> <meta content='415944175093180' property='fb:app_id'/> <meta content='Browser Detect' property='og:title'/> <meta content='Tells about Early days' property='og:description'/> <meta content='http://example.com/test.html' property='og:url'/> <meta content='http://example.com/test.html' property='og:image'/> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId: '415944175093180', status: true, cookie: true, xfbml: true,oauth: true}); }; (function() { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); </script> <fb:comments href="http://example.com/test.html" num_posts="20" width="470" /> </body>
Android Code:
public class SimpleActivity extends the action {
WebView web1; ViewPager awesomePager; Context cxt; List<WebView> data; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); cxt = this; data = new ArrayList<WebView>(); awesomePager = (ViewPager) findViewById(R.id.viewPager); awesomePager.setOffscreenPageLimit(10); WebView web1 = new WebView(cxt); web1.loadUrl("http://example.com/test.html"); WebSettings webSettings1 = web1.getSettings(); webSettings1.setJavaScriptEnabled(true); data.add(web1); awesomePager.setAdapter(new AwesomePagerAdapter(this,data));
}
Prax
source share