Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Like button in Android Application

I want to display like button in my android application. Below is the code I use to display a Like button in my android application.

String url = "http://www.facebook.com/plugins/like.php?layout=standard&show_faces=true&width=80&height=50&action=like&colorscheme=light&href=http://beta.demo.dy/web/service/304.htm"
webview = (WebView) findViewById(R.id.webView1);
webview.loadUrl(url);
webview.setWebViewClient(new LikeWebviewClient());

public class LikeWebviewClient  extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

But when I run this application it displays a white area. How to resolve this?

like image 591
Megha Avatar asked Oct 17 '11 13:10

Megha


1 Answers

The like option can be implemented easily on Native platform languages(Android, iOS) as well as browsers (curl, PHP, JavaScript) as follows. Go to developer.facebook app section and within the Open Graph section of the Developer App configuration, add the built-in Like action, which should appear in the drop-down when adding a new Open Graph action. Refer here for latest updates.

Once done, Select "Get Code" option to retrieve sample code as depicted below for Android platform. You can choose platform of your choice. Note that app_specific_unique_identifier is uniquee for apps, i have removed it for security reasons and you have to use the one for your app.

I have been able to test the Like flow successfully. Hope this helps.

Bundle params = new Bundle();
params.putString("object", "http://samples.ogp.me/<app_specific_unique_identifier>");

Request request = new Request(
    Session.getActiveSession(),
    "me/og.likes",
    params,
    HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
like image 115
Birender Singh Avatar answered Sep 28 '22 18:09

Birender Singh