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

2

4

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

Petronilapetronilla answered 11/7, 2013 at 14:27 Comment(2)
read this post, there is complete solution: blog.shamanland.com/2014/06/…Bumbling
It is outdated solutionTilton
B
7

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

Bumbling answered 25/5, 2014 at 9:35 Comment(4)
How does this react on click? Is it dependant on previous Facebook login, or does it somehow open in browser or similar? What if user isn't logged in on Facebook (or have it)?Uneducated
It will open dialog with WebView. This web-view will keep user session.Bumbling
I have "Namespace 'app' is not bound' error on XML.Tilton
You have to add this line to the first tag in your layout: xmlns:app="http://schemas.android.com/apk/res-auto"Bumbling
R
-1

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;
                    }
                }
Remainderman answered 11/7, 2013 at 14:31 Comment(2)
thanks akram!! but when I press the like button visualized in webview do not happen nothingPetronilapetronilla
I think the user must be logged in his Fb account to like the page.Remainderman

© 2022 - 2024 — McMap. All rights reserved.