Search code examples
androideclipsefacebook-android-sdkfacebook-share

Error in Using ShareDialog for Facebook SDK


I have imported Facebook SDK into Eclipse without errors and I am trying to follow the instructions here to use the ShareDialog.

Here is the error I see. Not sure where to import the class Result from? As you can see the other Facebook SDK Classes have imported fine.

enter image description here

Here's the code:

FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);
    // this part is optional
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {

        @Override
        public void onSuccess(Result result) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onCancel() {
            // TODO Auto-generated method stub

        }

        @Override
        public void onError(FacebookException error) {
            // TODO Auto-generated method stub

        }

        });

Solution

  • You should import:

     import com.facebook.share.Sharer;
    

    and change your:

          @Override
             public void onSuccess(Result result){
    

    for

          @Override
            public void onSuccess(Sharer.Result result) {
                // TODO Auto-generated method stub
    
            }
    

    This worked for me