ShareDialog立即关闭 [英] ShareDialog dismiss immediately

查看:147
本文介绍了ShareDialog立即关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Android应用中添加ShareFacebook按钮.

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

当我使用我的FB帐户(与Facebook开发者控制台一起使用的那个帐户)时,代码可以工作,并且我可以毫无问题地共享FB上的链接.

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.

但是,当我使用其他FB帐户测试该应用程序时,共享对话框出现并消失 非常快.

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?

这是我的代码:

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


                }

        }

    });

由于我可以与我的Fb共享,所以我猜代码很好,所以它可能是配置或参数问题,但我不知道从哪里开始.有帮助吗?

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?

推荐答案

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

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"/>

这篇关于ShareDialog立即关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆