我通過Gradle使用Facebook Android sdk 4.6.0
。Facebook分享視頻例外「ShareVideo必須參考Android設備上的視頻」
我試圖根據Sharing on Facebook guidenline配置Facebook後,從移動目錄上傳視頻,但在sharedialog.show調用後,我收到異常「ShareVideo必須引用設備上的視頻」。這個異常通過`onError(FacebookException異常)回調報告給我。
/**first checking if file exist than execute code, file exits and code execute but after executing callback with exception "Share Video must reference a video that is on the device" occurs
**/ private void shareOnFacebook() {
File dir = new File(Environment.getExternalStorageDirectory(),
"directory");
File video = new File(dir, "Video.mp4");
if (video.exists()) {//if video file exist
Uri videoFileUri = Uri.parse(video.getPath());
ShareVideo sv = new ShareVideo.Builder()
.setLocalUrl(videoFileUri)
.build();
ShareVideoContent content = new ShareVideoContent.Builder()
.setVideo(sv)
.build();
shareDialog.show(content); //show facebook sharing screen with video
}
}
你的回答是完美的,代碼 從這個「Uri videoFileUri = Uri.parse(video.getPath());」的變化 「Uri videoFileUri = Uri.fromFile(video);」 –