android系统自带分享视频

使用android系统的分享功能。

多视频分享:

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

单视频分享:

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

猜你喜欢

转载自blog.csdn.net/howlaa/article/details/131698178
今日推荐