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);
以上是从我的Android应用程序在Facebook上共享URL的代码。我可以在Facebook上分享它,但是当共享成功时,我想在我的应用程序中显示Toast消息,无论共享是否成功。如何工作我无法得到这段代码的问题。我是应用程序开发的新手。