无法共享视频';通过Android Intent.ACTION\u发送Facebook上的URL

无法共享视频';通过Android Intent.ACTION\u发送Facebook上的URL,android,facebook,url,video,share,Android,Facebook,Url,Video,Share,我需要以编程方式共享视频资源上的URL。 URL的示例是 我使用Intent.ACTION\u发送: Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test subject"); sendIntent.putExtra(Intent.EXTRA_TEXT, "http://flash.video.worldnow.com/kold/KOLD_201107

我需要以编程方式共享视频资源上的URL。 URL的示例是

我使用Intent.ACTION\u发送:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test subject");
sendIntent.putExtra(Intent.EXTRA_TEXT, "http://flash.video.worldnow.com/kold/KOLD_20110714204221200AA.mp4");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent,
                "Share URL"));
Facebook android应用程序无法处理URL,并显示以下错误:

“flash对象必须具有'swfsrc'和'imgsrc'属性”


如何避免错误?如何将所需的属性放入“text/plain”消息中?

看看这个页面,它似乎希望swfsrc和imgsrc编码在JSON编码的数组中。希望这有帮助。

看看这个页面,它似乎希望swfsrc和imgsrc编码在JSON编码的数组中。希望这能有所帮助。

我查看了Facebook应用程序源(ShareLinkActivity),没有发现任何向共享请求添加必填字段的可能性。仅使用intent额外参数intent.extra_文本的内容。

我查看了Facebook应用程序源(ShareLinkActivity),没有发现任何向共享请求添加必填字段的可能性。仅使用intent extra parameter intent.extra_文本的内容。

经过几个小时的尝试,了解如何在facebook、youtube、instagram和whatsapp上上传和共享视频。这是对我有用的代码。将录制的视频从应用程序上载到社交媒体应用程序

处理视频时尝试使用ContentValues,并在内容中指定MediaStore.Video.Media.Data

ContentValues content = new ContentValues(4);
        content.put(Video.VideoColumns.DATE_ADDED,
        System.currentTimeMillis() / 1000);
        content.put(Video.Media.MIME_TYPE, "video/mp4");
        content.put(MediaStore.Video.Media.DATA, "your_path_to_video");
        ContentResolver resolver = getBaseContext().getContentResolver();
        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("video/*");
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
        sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
        startActivity(Intent.createChooser(sharingIntent,"share:")); `

经过几个小时的努力,我们终于找到了在facebook、youtube、instagram和whatsapp上上传和分享视频的方法。这是对我有用的代码。将录制的视频从应用程序上载到社交媒体应用程序

处理视频时尝试使用ContentValues,并在内容中指定MediaStore.Video.Media.Data

ContentValues content = new ContentValues(4);
        content.put(Video.VideoColumns.DATE_ADDED,
        System.currentTimeMillis() / 1000);
        content.put(Video.Media.MIME_TYPE, "video/mp4");
        content.put(MediaStore.Video.Media.DATA, "your_path_to_video");
        ContentResolver resolver = getBaseContext().getContentResolver();
        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("video/*");
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
        sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
        startActivity(Intent.createChooser(sharingIntent,"share:")); `

我搜索了将近7个小时,下面是唯一一个对我来说非常有效的解决方案

 File filePath = filesList[position]; 
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_TEXT, "Text");
            shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filesList[position].getAbsolutePath())));  //optional//use this when you want to send an image
            shareIntent.setType("video/mp4");
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(shareIntent, "send"));

我搜索了将近7个小时,下面是唯一一个对我来说非常有效的解决方案

 File filePath = filesList[position]; 
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_TEXT, "Text");
            shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filesList[position].getAbsolutePath())));  //optional//use this when you want to send an image
            shareIntent.setType("video/mp4");
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(Intent.createChooser(shareIntent, "send"));

谢谢你的回答,但我不使用JSON请求。我需要使用常用的Android功能进行发送(即Intent.ACTION\u SEND)。在这种情况下,任何社交客户端(如Facebook、Twitter等)都可以处理相同的意图,也可以通过短信、彩信和电子邮件发送。我需要找到一种方法,如何将上述Facebook字段所需的内容放在简单的文本消息中,并通过Intent进行共享。您可以将JSON编码的数组作为额外文本放在Intent中!在Facebook上,流附件是定义帖子的结构化数据数组!在我的例子中,Content Intent.EXTRA_文本不能是JSON。此文本在Twitter上共享时仍然有效。应该使用什么额外的参数名称将附件放入IntentExtra?我试着把它命名为“附件”,但没有成功:sendIntent.putExtra(“附件”,“媒体”:[{“类型”:“flash\”,“swfsrc\”:“+”flash.video.worldnow.com/kold/kold\u 20110718232729103AC.mp4”;“+”,“imgsrc\:“icanhascheezburger.files.wordpress.com/2009/04/…”));仅供参考:Parameter name Intent.EXTRA_文本也被尝试过,Facebook的ShareUrlActivity也忽略了它谢谢你的回答,但我不使用JSON请求。我需要使用常用的Android功能进行发送(即Intent.ACTION\u SEND)。在这种情况下,任何社交客户端(如Facebook、Twitter等)都可以处理相同的意图,也可以通过短信、彩信和电子邮件发送。我需要找到一种方法,如何将上述Facebook字段所需的内容放在简单的文本消息中,并通过Intent进行共享。您可以将JSON编码的数组作为额外文本放在Intent中!在Facebook上,流附件是定义帖子的结构化数据数组!在我的例子中,Content Intent.EXTRA_文本不能是JSON。此文本在Twitter上共享时仍然有效。应该使用什么额外的参数名称将附件放入IntentExtra?我试着把它命名为“附件”,但没有成功:sendIntent.putExtra(“附件”,“媒体”:[{“类型”:“flash\”,“swfsrc\”:“+”flash.video.worldnow.com/kold/kold\u 20110718232729103AC.mp4”;“+”,“imgsrc\:“icanhascheezburger.files.wordpress.com/2009/04/…”));仅供参考:还尝试了参数name Intent.EXTRA_文本,Facebook的ShareUrlActivity也忽略了该文本