简体   繁体   English

Android Facebook分享对话框回调

[英]Android Facebook share dialog callback

I'm trying to include a simple Facebook sharing dialog in my app with the Facebook sdk. 我正在尝试使用Facebook sdk在我的应用程序中包含一个简单的Facebook共享对话框。 I did everything like described in the sharing tutorial: https://developers.facebook.com/docs/android/share?locale 我做了共享教程中所述的所有操作: https : //developers.facebook.com/docs/android/share?locale

In the onActivityResult Callback i use the uiHelper callback 在onActivityResult回调中,我使用uiHelper回调

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
        @Override
        public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
            Log.e("Activity", String.format("Error: %s", error.toString()));
        }

        @Override
        public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
            boolean didCancel = FacebookDialog.getNativeDialogDidComplete(data);
            String completionGesture = FacebookDialog.getNativeDialogCompletionGesture(data);
            String postId = FacebookDialog.getNativeDialogPostId(data);
            Log.i("Activity", "Success!");
        }
    });

}

didCancel is always true - doesn't matter if i post on my wall or not. didCancel始终为真-无论是否贴在墙上都没关系。 completionGesture and postId is always null. completeGesture和postId始终为null。 Is there a way without requesting permission to get a callback weather the user posted on his wall or not? 有没有一种方法可以不要求获得用户在其墙上张贴的回调天气的许可?

From the javadocs - https://developers.facebook.com/docs/reference/android/current/class/FacebookDialog#getNativeDialogDidComplete - this method will return true if the native dialog completed normally (without error or exception). 从javadocs- https://developers.facebook.com/docs/reference/android/current/class/FacebookDialog#getNativeDialogDidComplete-如果本机对话框正常完成(没有错误或异常),则此方法将返回true。 So if the user clicks on either the Share/Post button, or Cancel, the dialog completed normally. 因此,如果用户单击“共享/发布”按钮或“取消”,则对话框正常完成。 It's only when there's an error will this method return false. 只有在出现错误时,此方法才会返回false。

As for completion gesture, see the Android sharing doc's handling responses section - https://developers.facebook.com/docs/android/share#linkshare-handlingresponses - You will only get those fields if the user has logged in with Facebook Login via your app. 至于完成手势,请参阅Android共享文档的处理响应部分-https://developers.facebook.com/docs/android/share#linkshare-handlingresponses-仅当用户使用Facebook登录通过以下方式登录时,您才会获得这些字段您的应用。 It is not available if the user has not logged in via your app. 如果用户尚未通过您的应用程序登录,则该功能不可用。

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

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