user2509300
user2509300

Reputation: 271

How to add to my android application a button than do like to a facebook page?

I've tried this: https://github.com/crowjdh/android-facebook-like-button-integration

but it not work. I search something more simple than do "like" to my facebook page when user press a button to android application I'm developing. thank you

Upvotes: 4

Views: 8087

Answers (2)

Oleksii K.
Oleksii K.

Reputation: 5419

Use this library: Facebook Like button for Android. There is detailed manual here.

Sources: https://github.com/shamanland/facebook-like-button

Gradle dependency:

repositories {
    mavenCentral()
}

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

The simplest way to add like button:

<com.shamanland.facebook.likebutton.FacebookLikeButton
    style="@style/Widget.FacebookLikeButton"
    app:pageUrl="http://blog.shamanland.com/"
    app:pageTitle="Developer's notes"
    app:pageText="This is blog about Android development."
    app:pagePicture="@drawable/ic_launcher"
    />

This view will be drawn in your layout: enter image description here

In additional there is box with count of likes.

enter image description here

Upvotes: 7

Akram Fares
Akram Fares

Reputation: 1683

You can create a webview and put your button inside.

You can try something like this :

 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.webview);
                webView.loadUrl(url);
                 webView.setWebViewClient(new WebViewClient());
             class LikeWebviewClient  extends WebViewClient
                {
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        view.loadUrl(url);
                        return true;
                    }
                }

Upvotes: -1

Related Questions