Amal Dev S I Amal Dev S I - 1 year ago 98
Android Question

How to implement facebook comment plugin in Android

How to implement Facebook comments plugin in Android, which allows users to post comments to their wall as shown in the image given below ?

Answer Source

maybe this is not what you looking for but i found few ideas that you could start rolling from like there is a Graph API Facebook social plugin on android or in a WebView Android unable to implement facebook comment in a webview due to default browser

Edit: Should work if you set proper domain and path that already has comments. Haven't checked how it will if original path doesn't have comments

package com.example.ff;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {
// changeable public variables 
    public static String APP_KEY = "You're app key";
    public static String BASE_DOMAIN = "";
    public static String PATH_URL = "/tv/p/anNBpr";

    private WebView webView;
    private MainActivity context;

    protected void onCreate(Bundle savedInstanceState) {
        context = this;
        CookieManager cm = CookieManager.getInstance();
        webView = (WebView) findViewById(;
                "<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); = id;js.src = \""+APP_KEY+ "\";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script><div class=\"fb-comments\" data-href=\""
        +BASE_DOMAIN+PATH_URL+"\" data-width=\"470\"></div> </body></html>", "text/html", null, null);
        webView.setWebViewClient(new WebViewClientActivity());
    public class WebViewClientActivity extends WebViewClient {
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            System.out.println("onPageStarted: " + url);


        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;

        public void onPageFinished(WebView webView, String url) {
            System.out.println("onPageFinished: " + url);

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        return super.onOptionsItemSelected(item);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download