Reputation: 309
Inside my fragment I have an OnactiviyResult that contains:
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) {
Log.d("Activity", "Success!");
boolean isComplete = FacebookDialog.getNativeDialogDidComplete(data);
String postId = FacebookDialog.getNativeDialogPostId(data);
if (isComplete) {
String completionGesture = FacebookDialog.getNativeDialogCompletionGesture(data);
if (completionGesture == null || FacebookDialog.COMPLETION_GESTURE_CANCEL.equals(completionGesture)) {
//Show Publish Cancel Toast
Toast.makeText(getActivity(), "User canceled facebook post", Toast.LENGTH_SHORT).show();
} else {
if (postId != null) {
Toast.makeText(getActivity(), "user published", Toast.LENGTH_SHORT).show();
try {
ParseObject game = new ParseObject("Deal");
game.put("User", user_ID);
game.save();
} catch (ParseException e) {
e.printStackTrace();
} finally {
Toast.makeText(getActivity(), "got" + user_ID, Toast.LENGTH_SHORT).show();
}
}
}
}
}
});
The problem that It never gets to it. nothing is returned. Calling it like that:
uiHelper.trackPendingDialogCall(shareDialogBuilder.build().present());
Now I found out that it is happening because of the fragment in this question: Facebook Intent share doesnt show Activity result on share click
He says "All I did was to export those codes into my MainActivity" How exactly It should look? Thanks
Upvotes: 0
Views: 355
Reputation: 13947
You need to do
shareFacebookDialog.setFragment(this);
where "this" is the fragment
to get the callback in the fragment
when you get the result in the onActivityResult
you may need to do resultCode&0xffff
as some android versions had a bug with this, and changed the requestcode without turning it back
Upvotes: 1