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

戏子无情 提交于 2019-11-26 04:27:29

问题


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


回答1:


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:

In additional there is box with count of likes.




回答2:


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;
                    }
                }


来源:https://stackoverflow.com/questions/17596070/how-to-add-to-my-android-application-a-button-than-do-like-to-a-facebook-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!