FacebookCallback<Sharer.Result> shareCallback = new FacebookCallback<Sharer.Result>() {
@Override
public void onCancel() {
Log.d("cancled", "fb SHARE canceled");
}
@Override
public void onError(FacebookException error) {
Log.d("Error", "fb SHARE error");
}
@Override
public void onSuccess(Sharer.Result result) {
String postId = result.getPostId();
if (postId != null)
{
// record successful FB share
Log.d("Success", "fb SHARE success");
}
}
};
Log.d("facebook", "inside");
shareDialog = new ShareDialog(getActivity());
CallbackManager callbackManager = CallbackManager.Factory.create();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(sharefburl))
.build();
shareDialog.show(content,ShareDialog.Mode.FEED);
shareDialog.registerCallback(callbackManager, shareCallback);
The above is the code to share a URL on Facebook from my android application. I am able to share it on Facebook but when the share is successful I want to display a Toast message in my application whether the share was successful or not. How will that work I am not able to get what is the problem with this code. I am newbie in application development.