Android system comes with video sharing

Use the sharing function of the android system.

Multiple video sharing:

private void showShare() {
        List<AlbumData> albumDataList = mAlbumListViewModel.getCheckedDataList().getValue();
        if (albumDataList == null || albumDataList.isEmpty()) {
            return;
        }
        List<Uri> videoUris =
                albumDataList.stream().map(AlbumData::getUri).collect(Collectors.toList());
        Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<>(videoUris));
        shareIntent.setType("video/*");
        requireContext().startActivity(Intent.createChooser(shareIntent, ""));
    }

Single video sharing:

public void share(AlbumData albumData) {
            if (albumData == null || albumData.getUri() == null) {
                return;
            }
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_STREAM, albumData.getUri());
            shareIntent.setType("video/*");
            requireContext().startActivity(Intent.createChooser(shareIntent, ""));
        }

Guess you like

Origin blog.csdn.net/howlaa/article/details/131698178