Sweety Bertilla
Sweety Bertilla

Reputation: 1032

Share video and save video to Gallery

I have video url, from which I parse to to get the uri. I try to pass the uri in share, but I don't see the video being shared.

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

Am I missing something here, or should I save the uri to external storage and then pass it?

Also I need to know how to save the video using the uri to Gallery.

Upvotes: 2

Views: 4523

Answers (2)

Peter Zaw
Peter Zaw

Reputation: 9

Intent.createChooser seems to be missing. Please see the code snippet and the link.

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"));

The link:
http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/

Upvotes: 0

Dmila Ram
Dmila Ram

Reputation: 1074

use this:

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"));

"path" is your videos pass like /sdcard/mVideo.mp4

Upvotes: 3

Related Questions