如何在Android上与Facebook共享视频

如何在Android上与Facebook共享视频,android,android-facebook,Android,Android Facebook,我试着从你那里得到一份推荐信 这是我的步骤 步骤1:尝试导入Facebook SDK repositories { mavenCentral() } dependencies { ... compile 'com.android.support.constraint:constraint-layout:1.0.2' ... } 步骤2:在清单上设置代码,333991926986699是我的Facebook应用程序id 我不知道如

我试着从你那里得到一份推荐信

这是我的步骤

步骤1:尝试导入Facebook SDK

    repositories {
        mavenCentral()
    }

    dependencies {
...
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
...
    }
步骤2:在清单上设置代码,333991926986699是我的Facebook应用程序id

我不知道如何让它工作

这是我的视频。谁能教我下一步该怎么做

任何帮助都将不胜感激

以下是我尝试分享的代码:

shareButton=(Button)findViewById(R.id.shareButton);

        shareButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Uri videoFileUri=Uri.parse("https://www.youtube.com/watch?v=zeLqNx7dMBM");
                ShareVideo shareVideo=new ShareVideo.Builder()
                        .setLocalUrl(videoFileUri)
                        .build();
                //There is no use by content
                ShareVideoContent content=new ShareVideoContent.Builder()
                        .setVideo(shareVideo)
                        .build();
            }
        });

您正在尝试共享链接,但正在使用代码共享设备上的视频

请看一看

并尝试使用代码共享链接

ShareLinkContent content = new ShareLinkContent.Builder()
        .setContentUrl(Uri.parse("https://developers.facebook.com"))
        .build();
请考虑到您必须使用Facebook共享按钮。请看下面的图片


您不能使用标准的Android按钮

是否要上载该视频或共享视频的链接?我想共享链接。好的,我明白了。你说“我不知道该怎么做”是什么意思?它会抛出错误吗?也许你应该发布你的代码,说明你是如何将facebook示例集成到你的应用程序中的。没有可能出错,我认为我的内容没有用。我更新了关于try to share.ShareLinkContent content=new ShareLinkContent.Builder.setContentUrlUri.parse.build的代码;应该工作得很好谢谢你的回答,但是我试着用这个代码做一个按钮,它不工作,我会错过什么吗?我的意思是它不会显示任何用于共享视频的布局或对话框
shareButton=(Button)findViewById(R.id.shareButton);

        shareButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Uri videoFileUri=Uri.parse("https://www.youtube.com/watch?v=zeLqNx7dMBM");
                ShareVideo shareVideo=new ShareVideo.Builder()
                        .setLocalUrl(videoFileUri)
                        .build();
                //There is no use by content
                ShareVideoContent content=new ShareVideoContent.Builder()
                        .setVideo(shareVideo)
                        .build();
            }
        });
ShareLinkContent content = new ShareLinkContent.Builder()
        .setContentUrl(Uri.parse("https://developers.facebook.com"))
        .build();
ShareButton shareButton = (ShareButton)findViewById(R.id.fb_share_button);
shareButton.setShareContent(content);