1

I want to share image on Facebook with my android app. I use this code:

  SharePhoto photo = (SharePhoto)new SharePhoto.Builder().SetBitmap(bitmap).Build();

  SharePhotoContent content = new SharePhotoContent.Builder()
                    .AddPhoto(photo)
                    .Build();

  _fbShareButton.ShareContent = content;

The problem is that i can only publish from account where i created facebook app. After login to another account the share window doesn't appear.

The app is online on facebook developer account.

Thanks in advance! :)

bigjoe1
  • 117
  • 1
  • 12

2 Answers2

0

First You have to make your app public in facebook developer. To make public Follow this steps given in this link https://stackoverflow.com/a/37982567/7235539

Hope its help You.

Community
  • 1
  • 1
Patel Pinkal
  • 8,984
  • 4
  • 28
  • 50
0
         //If Your are in debug mode please make sure that you are login with developer id from which app is registered       

 FacebookSdk.sdkInitialize(context);//initialize your Facebook SDK

                 //Obtain Callback manager instance
                 CallbackManager   callbackManager = CallbackManager.Factory.create();

                  //Create facebook Share Dialog instance
                ShareDialog    shareDialog = new ShareDialog((AppCompatActivity) context

                  //Register CallBack
                    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
                        @Override
                        public void onSuccess(Sharer.Result result) {

                        }

                        @Override
                        public void onCancel() {

                        }

                        @Override
                        public void onError(FacebookException error) {
                            error.printStackTrace();
                        }
                    });

                     //Perform Click event on your share button
fb_share_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (ShareDialog.canShow(ShareLinkContent.class)) {
                    ShareLinkContent content = new ShareLinkContent.Builder()
                            .setContentUrl(Uri.parse(context.getString(R.string.app_link_to_play_store)))//this is your play store link
                            .setContentTitle(context.getString(R.string.app_name))
                            .setContentDescription(context.getString(R.string.description_content_fb))//content to display on facebook
                            .setImageUrl(Uri.parse("Your image url placed on app server"))
                            .build();
                    shareDialog.show(content);
                }
            }
        });
Gautam Dev
  • 399
  • 2
  • 4