Fabian
Fabian

Reputation: 2713

Android Facebook share dialog callback

I'm trying to include a simple Facebook sharing dialog in my app with the Facebook sdk. I did everything like described in the sharing tutorial: https://developers.facebook.com/docs/android/share?locale

In the onActivityResult Callback i use the uiHelper callback

@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. completionGesture and postId is always null. Is there a way without requesting permission to get a callback weather the user posted on his wall or not?

Upvotes: 1

Views: 4108

Answers (1)

Ming Li
Ming Li

Reputation: 15662

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

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. It is not available if the user has not logged in via your app.

Upvotes: 1

Related Questions