简体   繁体   English

如何在 Android 应用程序中将视频 (.mp4) 分享到社交媒体?

[英]How to share video (.mp4) to social media in Android App?

I've looked in stackoverflow and saw some posts on how to share a video from the phone to another app, but none seem to work.我查看了 stackoverflow 并看到了一些关于如何将视频从手机共享到另一个应用程序的帖子,但似乎都没有。 I followed the following guide: http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/ but this also appears to not work.我遵循了以下指南: http : //sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/但这似乎也不起作用。 Does anyone have a short snippet of code to properly share a video?有没有人有一小段代码可以正确分享视频? The following does not work with SMS Messaging, Inbox, Gmail, Google+, Facebook, or Messenger.以下不适用于 SMS Messaging、Inbox、Gmail、Google+、Facebook 或 Messenger。

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri videoUri = Uri.parse("/storage/emulated/0/DCIM/Camera/video.mp4");

sharingIntent.setType("video/mp4");
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
startActivity(Intent.createChooser(sharingIntent, "Share video using"));

Without seeing the rest of your code or the error stacktrace is difficult to tell what is going wrong.如果没有看到您的代码的其余部分或错误堆栈跟踪,就很难判断出了什么问题。

But I would say maybe check the Uri you are providing is right and the video path matches with that one.但我想说也许检查您提供的 Uri 是否正确,并且视频路径与该路径匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM