ShareDialog dismiss immediately

我怕爱的太早我们不能终老 提交于 2019-12-12 04:48:03

问题


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?


回答1:


Have you found any stack trace?
You must look if you have initialized facebook SDK or not

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

and if it is showing, and dismissing, then there must be

<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
      android:name="com.facebook.FacebookContentProvider"
      android:exported="true"/>


来源:https://stackoverflow.com/questions/46080921/sharedialog-dismiss-immediately

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