0

I 'm trying to add a ShareFacebook button in my android app.

The code works when I use my FB account, the one I used with Facebook Developer Console and I can share the link on my FB with no problem.

But, when I tested the app with an other FB account, the share dialog appears and disappeares very fast.

I have no clue why, any help?

Here's my code:

facebook.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

                ShareDialog shareDialog = new ShareDialog(ScoreActivity.this);

                if (ShareDialog.canShow(ShareLinkContent.class)) {
                    ShareLinkContent linkContent = new ShareLinkContent.Builder()
                            .setContentUrl(Uri.parse("..."))
                            .build();

                    shareDialog.show(linkContent);


                }

        }

    });

Since I can share with my Fb then I guess the code is fine, So it's probably a configuration or a parameter issues, but I have no idea where to start. Any help?

4

1 回答 1

0

你有没有找到任何堆栈跟踪?
您必须查看是否已初始化 facebook SDK

FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
    // this part is optional
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { ... });

如果它正在显示和关闭,那么必须有

<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
      android:name="com.facebook.FacebookContentProvider"
      android:exported="true"/>
于 2017-09-07T15:16:21.827 回答