【问题标题】:Share video and save video to Gallery分享视频并将视频保存到图库
【发布时间】:2014-10-08 17:22:46
【问题描述】:

我有视频 url,我从中解析以获取 uri。我尝试在共享中传递 uri,但我没有看到正在共享的视频。

Uri uri = Uri.parse(url);
Intent sharingIntent = new Intent(
                    Intent.ACTION_SEND);
sharingIntent.setType("video/*");
                        sharingIntent.putExtra(Intent.EXTRA_STREAM,uri
                               );
startActivity(sharingIntent);

我在这里遗漏了什么,还是应该将 uri 保存到外部存储然后传递它?

我还需要知道如何使用 uri 将视频保存到图库。

【问题讨论】:

  • 有什么答案或建议吗?
  • 任何帮助将不胜感激...

标签: android android-intent android-gallery


【解决方案1】:

使用这个:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/mp4");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
startActivity(Intent.createChooser(intent, "share"));

“路径”是您的视频传递,例如 /sdcard/mVideo.mp4

【讨论】:

    【解决方案2】:

    Intent.createChooser 似乎不见了。请看代码sn-p和链接。

    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    Uri screenshotUri = Uri.parse(path);
    
    sharingIntent.setType("image/png");
    sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
    startActivity(Intent.createChooser(sharingIntent, "Share image using"));
    

    链接:
    http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/

    【讨论】:

    • 感谢您的回答,我可以看到要发送的选项列表,例如 Facebook、GMAIL 等。当我选择 GMAIL 时,我看到发送的电子邮件没有附加视频。
    • 我的意思是没有您的回答,我可以看到选项列表。我的主要问题是视频没有被发送。你能帮我解决这个问题吗?
    • 我尝试了类似的方法。它起作用了 - 将视频文件作为电子邮件附件接收。您可能需要检查视频文件的大小。另外,请看下面。 stackoverflow.com/questions/15965246/…类型需要为:sharingIntent.setType("video/*");
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2020-01-15
    相关资源
    最近更新 更多