2015-06-08 50 views
1

我想通過最新的Facebook sdk分享視頻。通過Facebook分享視頻sdk 4.x在Android應用程序

我嘗試這樣做,以這樣的方式

if (ShareDialog.canShow(ShareVideoContent.class)) { 
    Uri videoFileUri = Uri.parse(mFileMP4.getAbsolutePath()); 
    ShareVideo shareVideo = new ShareVideo.Builder() 
     .setLocalUrl(videoFileUri) 
     .build(); 
    ShareVideoContent content = new ShareVideoContent.Builder() 
     .setVideo(shareVideo) 
     .build(); 

    shareDialog.show(content); 
} 

,我得到這個錯誤:

com.facebook.a.a﹕ Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject 

有人知道這是怎麼回事?

+0

我有同樣的錯誤,儘管我沒有任何交流。我只是設置了新的登錄小工具,並且每5秒拋出相同的錯誤 – UrielUVD

回答

0

你是否嘗試將視頻uri轉換爲字符串?像這樣:

.setLocalUrl(videoFileUri.toString()) 
+0

是的,但它不能是字符串。它必須是uri。 –

0

試試這個代碼

Uri videoFileUri = ... 
ShareVideo = new ShareVideo.Builder() 

     .setLocalUrl(videoUrl) 
     .build(); 
ShareVideoContent content = new ShareVideoContent.Builder() 

     .setVideo(video) 
     .build(); 

參照此方https://developers.facebook.com/docs/sharing/android

相關問題