我通过Gradle使用Facebook Android sdk 4.6.0.
我正在尝试根据Sharing on Facebook guidenline配置Facebook后从移动目录上传视频,但我得到例外“ShareVIDeo必须引用设备上的视频”在sharedialog.show调用之后.通过对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 } }
解决方法:
抛出异常:
https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/share/internal/ShareContentValidation.java;
if (!Utility.isContentUri(localUri) && !Utility.isfileUri(localUri)) {throw new FacebookException("ShareVIDeo must reference a vIDeo that is on the device");}public static boolean isContentUri(final Uri uri) {return (uri != null) && ("content".equalsIgnoreCase(uri.getScheme()));}public static boolean isfileUri(final Uri uri) {return (uri != null) && ("file".equalsIgnoreCase(uri.getScheme())); }
如你所见,fb share sdk正在检查uri是否有一个方案.
在您的情况下,当您从vIDeo.getPath创建uri时,scheme为null.你应该做的是从视频文件创建uri:
Uri vIDeofileUri = Uri.fromfile(视频);
总结以上是内存溢出为你收集整理的Facebook分享视频例外“分享视频必须在Android上引用设备上的视频”全部内容,希望文章能够帮你解决Facebook分享视频例外“分享视频必须在Android上引用设备上的视频”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)