Android Facebook SDK AppInviteDialog CallBack Not

2019-07-18 03:59发布

Hey my friends i have a problem in the callback of the AppInviteDialog its not working i try many thing but without a result please help me :

public  void openDialogInvite(Activity activity)
{
    String appLinkUrl, previewImageUrl;

    appLinkUrl = "url";
    previewImageUrl = "img";

    if (AppInviteDialog.canShow())
    {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(appLinkUrl)
                .setPreviewImageUrl(previewImageUrl)
                .build();
        CallbackManager sCallbackManager = CallbackManager.Factory.create();
        AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
        appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
        {

            @Override
            public void onSuccess(AppInviteDialog.Result result) {
                Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_LONG).show();
            }

            @Override
            public void onCancel() {
                Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_LONG).show();
            }

            @Override
            public void onError(FacebookException error) {
                Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_LONG).show();
            }
        });

        appInviteDialog.show(content);
    }
}

enter code here

1条回答
The star\"
2楼-- · 2019-07-18 04:41

Did you invoked the CallbackManager into the onActivityResult method?

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult( requestCode, resultCode, data );
    callbackManager.onActivityResult( requestCode, resultCode, data );
}
查看更多
登录 后发表回答