在新的Android Fb SDK 4.0中,您可以根据文档为LoginButton注册回调。 https://developers.facebook.com/docs/facebook-login/android/v2.3

问题是AppInviteDialog也可能吗?还是有其他方法可以确定App-Invite是否成功?

最佳答案

是的,这是可能的。

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

    appLinkUrl = "your app link url";
    previewImageUrl = "https://www.example.com/my_invite_image.jpg";

    if (AppInviteDialog.canShow())
    {
        AppInviteContent content = new AppInviteContent.Builder()
                .setApplinkUrl(appLinkUrl)
                .setPreviewImageUrl(previewImageUrl)
                .build();

        AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
        CallbackManager sCallbackManager = CallbackManager.Factory.create();
        appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
        {
            @Override
            public void onSuccess(AppInviteDialog.Result result)
            {
            }

            @Override
            public void onCancel()
            {
            }

            @Override
            public void onError(FacebookException e)
            {
            }
        });

        appInviteDialog.show(content);
    }
}

10-06 14:27