berserk
berserk

Reputation: 2728

Share a video from SD card to other apps

I have an app which lists the video from a location in SD card. I want to share the video on different possible apps(like Whatsapp, gmail, facebook or bluetooth etc.). What intent should I call to acheive this action? I found this: Share image from SD Card but it is for image sharing. I also read: http://developer.android.com/training/sharing/shareaction.html but I didn't get it. I am viewing the videos in a listview and want to display a list of possible apps where I can share the video when I click it in list view.

EDIT: I am using this for now:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM,uri_for_file);
sendIntent.setType("file/*");
startActivity(Intent.createChooser(sendIntent,"Send video via:"));

but showing error when I tried to share on bluetooth: 11-18 17:49:59.275: E/BluetoothLauncherActivity(3249): type is null; or sending file URI is null

I checked using debugger, the uri_for_file variable has the exact uri where the video is stored.

Upvotes: 2

Views: 1345

Answers (1)

berserk
berserk

Reputation: 2728

The problem was, uri_for_file was string and I needed to parse it to Uri. Sorry to bother.

New Code:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse(uri_for_file));
sendIntent.setType("file/*");
startActivity(Intent.createChooser(sendIntent,"Send video via:"));

Upvotes: 0

Related Questions