June 12, 2014

How to add Facebook 'Like' button in Android app?

Official Facebook SDK does not provide implementation of theirs plugin 'Like' for Android. There is just html-plugin designed for web-sites and applications. Let's try to adapt this plugin for Android!

In this post we will look at the two things:

Using Facebook 'Like' button for single page

Just add single-line dependency in your gradle project:

dependencies {
    compile 'com.shamanland:facebook-like-button:0.1.8'

This library contains several widgets:

FacebookLikeButton - button which opens FacebookLikeActivity by clicking on it.

FacebookLikeBox - button with a specific background and with ability to check 'likes' count of your url.

FacebookLikePlugin - container which combines both FacebookLikeButton and FacebookLikeBox in different variations.

So, first you need is to include FacebookLikeButton with specified style in your layout:


Before configuring your button you need to add app xml namespace into the root node:


Add following attributes to your button: pageUrl - original url of page which should to be liked, pageTitle - title of this page, pageText - short description of page, pagePictureUrl - url of page picture.

    app:pageTitle="Title of your page"
    app:pageText="Short description of your page"

For example:

Do not forget to declare FacebookLikeActivity in your AndroidManifest.xml:


Make sure that you have internet permission:

<uses-permission android:name="android.permission.INTERNET"/>

That's all! Now you can compile and launch your app. When user clicks 'Like' button, then he will see WebView with official web-plugin 'Like' from Facebook:

Now, if you want to include box with count of 'likes' - you should use FacebookLikePlugin:

        app:pageTitle="Title of your page"
        app:pageText="Short description of your page"

Modified example:

Note about attribute calloutMarker: if you re-arrange 'like' and 'box' buttons, then you need to select corresponding value for calloutMarker: left, top, right, bottom.

Using Facebook 'Like' button in the ListView

There is no fundamental difference between single button and buttons inside ListView. You need just to set up button inside your Adapter.getView() method.

Use corresponding getters of class FacebookLikeButton: setPageUrl(), setPageTitle(), setPageText(), setPagePictureUrl().

NOTE: @style/Widget.FacebookLikeButton already has item android:id with the value R.id.com_shamanland_facebook_like. Use this value with method findViewById(). You can also override android:id in xml to use your own value.

Check this code example from library sources:
Well, I hope my library will help somebody to make awesome app with social features. Feel free to ask me anything, subscribe to repository and check for updates.

Project page: http://blog.shamanland.com/p/facebook-like-button.html
Sources: https://github.com/shamanland/facebook-like-button


  1. Whenever progressed admirably, endeavor versatile apps help business activities run all the more proficiently all through the associations and drive ROI. https://iphoneappdevelopmentcompany.com/ Be that as it may, associations center around the wrong approach to big business apps.

  2. Situs terbaik yang harus anda pilih adalah yang memang memiliki jaminan keamanan. Jaminan keamanan ini menjadi bagian yang sangat penting sekali dan sudah sebaiknya dan sewajarnya untuk anda bisa mendapatkannya
    bandar ceme
    freebet tanpa deposit
    paito warna terlengkap
    syair sgp

  3. This comment has been removed by the author.

  4. Free Android App Maker is extraordinary compared to other free utility to make an android application. Here one can submit Android application at application store in only couple of minutes.

  5. This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. appcloner's website

  6. Mobile developers are finding the platform extremely user-friendly. In the second quarter of the year 2012, approximately 105 million Android smartphones have been sold which represents an overall share of 68% of smartphone sales figures until that quarter.Cheat Engine APK

  7. This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted.By Learn Digital Marketing Course Training in Chennai it will help to get Digital Marketing Course Training with Placement Institute in Chennai. If you Learn Social Media Marketing Training with Placement Institute in Chennai, you will get job soon.

    Learn Best Digital Marketing Course Training in Chennai in professional institute to get reputed job.

  8. Contact them and tell them your requirement and ask them whether they can develop a mobile application as per your requirement at an affordable cost or not?Best Mobile app development Companies in India

  9. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. hack facebook

  10. To make Android advertise increasingly well known Android Application are free for everybody, he/she can download from various site. A large number of free apps been downloaded every day by Android client. Bulk SMS Service Provider in Sharjah UAE


  11. You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you.
    Tally ERP 9 Training
    tally classes
    Tally Training institute in Chennai
    Tally course in Chennai

  12. Pergi untuk taruhan luar, bukan yang di dalam. Menang dalam roulette mungkin bukan dalam memilih nomor yang menang tetapi dalam memilih apakah nomor yang menang berada di bawah

  13. As an enterprise mobile app developer, your app should endeavor to come with proper authentication plans, server-side validation, and encryption of essential data to overcome these security issues.Best Mobile App development Companies in UK