Android - mobile button

5 days ago, 10/02/2014, Facebook posted a new entry on its developer blog: "Mobile Like Button is now available to everyone": https://developers.facebook.com/blog/post/2014/10/02/mobilelike / and provided documentation: https://developers.facebook.com/docs/android/like-button

I tried to follow the documentation to get users like my application, but with no success:

  • The Like button does not show the number of apps you liked.
  • When I click the Like button, a white screen appears with a gray Facebook logo in the middle and bottom to top at the bottom. Has anyone successfully implemented this new button?

Here's what I did after the documentation on Facebook:

  • I created a Facebook page for my application and got its pageId, the code at the end of the page URL: https://www.facebook.com/pages/ [ myPage ]/ [myPageId ]
  • I added my app to my Facebook developer account and got ApplicationId: [myAppId]
  • I installed the Facebook SDK and added it to my Android project.

Then in the main activity of my application:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(this, callback);
    LikeView likeView = (LikeView) findViewById(R.id.like_view);
    likeView.setObjectId("[myPageId]");
...

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    uiHelper.onActivityResult(requestCode, resultCode, data, null);
...

      

In res / values ​​/ strings.xml, I added:

<string name="facebook_app_id">[MyAppId]</string>

      

in the AndroidManifest.xml file, I added in the Application tab:

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

      

+3


source to share


2 answers


Have you found any solution? I have been trying to get this Like button to work for a few days and have the same problem. I saw that you can add this to your button to have the number of likes, but it doesn't help me, maybe it can help in your case: likeView.setLikeViewStyle(LikeView.Style.BOX_COUNT);



- EDIT: I finally found a solution: it seams that you MUST NOT set a numerical height in the facebe of the LikeView, it should be wrapping the content. Hope it helps.

+1


source


When everything is confirmed correctly. Then don't forget to add your facebook account as your app tester so you can test the whole function. Also, if you want to use "as a button" with someone else, you must submit your application to Facebook and ask for "as a button" for this feature in Here



0


source







All Articles