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

Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27
AlgoMan
  • 33
  • 8
  • Facebook will already tell the user if it was successful or not. Why do you need to tell the user again? – WizKid Nov 26 '17 at 20:01
  • it does not when i post the url on Facebook the dialog box closes and it reaches back to my android application. Thats the reason i want to show a toast in my android application. @WizKid – AlgoMan Nov 26 '17 at 20:04

0 Answers0