4

I included FB login into my android app and it works fine. Now, I'd like to add the like button. Here is what I did:

  1. Following exactly the instructions given on https://developers.facebook.com/docs/android/like-button
  2. I create a LikeView in my layout.xml file:
<com.facebook.widget.LikeView
   android:id="@+id/LikeView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
</com.facebook.widget.LikeView>
  1. My code looks like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_reader);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    LikeView likeView = (LikeView) findViewById(R.id.LikeView);
    likeView.setObjectId("http://shareitexampleapp.parseapp.com/photo1/");
}
...
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data, null);
    Log.e("", "requestCode: " + requestCode);
    Log.e("", " resultCode: " + resultCode);
    Log.e("", "       data: " + data);
  1. This is the output:

requestCode: 64207 resultCode: 0 data: Intent { (has extras) }

  1. So my code points to the example page provided by FB. So it is out of question if the destination object id correctly configured.
  2. I'm not using any test account or similar. I use my real FB acccount for testing.

This is what happens:

  1. When clicking on the like view a blank page opens and then closes again
  2. The above stuff is printed to the logcat
  3. Nothing happened: No like or anything

Why does this 1 to 1 copy of the example not work?

toom
  • 12,864
  • 27
  • 89
  • 128

2 Answers2

0

I encountered exactly the same problem yesterday. I was not added as an administrator/a developer to the app on developers.facebook.com.

What you need to do:

  1. register yourself as a facebook developer (if you haven't done it yet)
  2. add your app through My Apps tab
  3. choose your app, click Roles (left menu) - your role should be Administrator (or Developer)

If the app already exists and someone else is an Administrator, ask him/her to add you there. You also need to add your phone number to your account in order to be added to your app.

untosabla
  • 96
  • 1
  • 2
  • 11
0

With the latest facebook SDK (ver 4.6.0), I found that this value (64207) turned out to be:

CallbackManagerImpl.RequestCodeOffset.Share.toRequestCode()

At this stage, I called

callbackManager.onActivityResult(requestCode, resultCode, data);

which resulted in my registered FacebookCallback<Sharer.Result> callback's onError function being called.

public void onError(FacebookException e)

The error was "Failed to get app name.". Searching for solutions to this mainly yielded answers to set the applicationName on FacebookDialog.ShareDialogBuilder, but that seems to be of an older version of the facebook sdk.

The solution that worked for me is disabling of the sandbox mode for the app as given here - How to disable Sandbox Mode for app in new Facebook Developer?

Hope that helps save someone time wading through the facebook docs quagmire.

EDIT: The sandbox-disable solution stopped working after some time. When I checked I had an older facebook app id. Once corrected, it worked.

Community
  • 1
  • 1
Rajath
  • 11,787
  • 7
  • 48
  • 62