简体   繁体   English

Facebook分享对话框未显示-Android Facebook API

[英]Facebook Share Dialog not showing - Android Facebook API

On clicking the facebook share button the share dialog comes and immediately disappears. 单击facebook共享按钮后,共享对话框就会出现,并立即消失。 In the shareDialog.registerCallback it goes to onError method. shareDialog.registerCallback它转到onError方法。 Don't understand why is it happening. 不明白为什么会这样。

CallbackManager callbackManager;
    ShareDialog shareDialog;

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
FacebookSdk.setApplicationId(String.valueOf(R.string.facebook_app_id));
        FacebookSdk.sdkInitialize(getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
        shareDialog = new ShareDialog(this);

shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
            @Override
            public void onSuccess(Sharer.Result result) {
                Toast.makeText(MainActivity.this, "onSuccess", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onCancel() {
                Toast.makeText(MainActivity.this, "onCancel", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(FacebookException error) {
                Toast.makeText(MainActivity.this, "Opps! Some error occurred. Please try again", Toast.LENGTH_SHORT).show();
            }
        });

bFbShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (ShareDialog.canShow(ShareLinkContent.class)) {
                    ShareLinkContent linkContent = new ShareLinkContent.Builder()
                      .setQuote("Hi ABCE")                     .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName()))
                            .build();
                    shareDialog.show(MainActivity.this, linkContent);
                }
            }
        });

In the Logcat i get this Logcat中,我得到了

GraphResponse: {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: 2131492917}

onClick删除if (ShareDialog.canShow(ShareLinkContent.class))是否对我if (ShareDialog.canShow(ShareLinkContent.class))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM