Pranesh Sahu Pranesh Sahu - 2 years ago 102
Android Question

Facing Issue while Sharing Video using Facebook SDK in android

I tried to share images using facebook sdk in android app - works like charm but when i tried to share video nothing happens.

The following is the code that i'm using for sharing video content:

@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.fb_share_button:
ShareVideo shareVideo1= new ShareVideo.Builder()
.setLocalUrl(Uri.parse("https://imdstar.com/clubapp/wp-content/uploads/2017/07/Chennaionline-AirtelParallelMusicFestival106-online-video-cutter.com_.mp4"))
.build();


ShareVideoContent shareContent = new ShareVideoContent.Builder()
.setVideo(shareVideo1)
.build();
shareButton.setShareContent(shareContent);
shareDialog.show(shareContent, ShareDialog.Mode.AUTOMATIC);
break;

default:
break;
}


}


The method is getting called on clicking share button but no dialog box appears for sharing.Please give me your valuable suggestion where i'm commiting mistake.

Answer Source

you are trying to share a link but you are using the code to share a video which is on your device.

Please have a look at

https://developers.facebook.com/docs/sharing/android

and try to use the code for sharing a link

ShareLinkContent content = new ShareLinkContent.Builder()
        .setContentUrl(Uri.parse("https://developers.facebook.com"))
        .build();

Please take into account that you have to use the Facebook Share Button. Please see at the bottom of https://developers.facebook.com/docs/sharing/android

ShareButton shareButton = (ShareButton)findViewById(R.id.fb_share_button);
shareButton.setShareContent(content);

You cannot use the standard Android Button

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download