我想将SD卡中的视频分享到Facebook。

      String path = Environment.getExternalStorageDirectory()
                            + File.separator + "Video" + File.separator + "Sample_new.mp4";

                ShareDialog  shareDialog = new ShareDialog(activity);

                    Uri videoFileUri = Uri.parse(path);
                    ShareVideo  ShareVideo = new ShareVideo.Builder()
                            .setLocalUrl(videoFileUri)
                            .build();
                    ShareVideoContent content = new ShareVideoContent.Builder()
                            .setVideo(ShareVideo)
                            .build();
                    shareDialog.show(content, ShareDialog.Mode.FEED);


但是我没有收到任何回复。请帮助我解决此问题。

最佳答案

/**Just try ti use below code Snipet**/

add dependency on build.gradle
compile 'com.facebook.android:facebook-android-sdk:4.7.0'

 Code in Activity:

 Make sure your are logged to Facebook using application.

private void postvideo(final String video_file_path,String Post_description)
{
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    GraphRequest request = GraphRequest.newPostRequest(accessToken, "me/videos", null, new GraphRequest.Callback()
    {
        @Override
        public void onCompleted(GraphResponse graphResponse)
        {


            Toast.makeText(Publish.this,"Video uploaded successfully on Facebook!!!",Toast.LENGTH_LONG).show();
        }
    });

    Bundle params = request.getParameters();
    try {
        byte[] data = readBytes(video_file_path);
        params.putByteArray("video.mp4", data);
        params.putString("title", "Your APP Name");
        params.putString("description", Post_description);
        request.setParameters(params);
        request.executeAsync();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

10-04 17:35