Android调起系统分享图片到其他应用

91 阅读1分钟
Android调起系统分享图片到其他应用

有时候分享不想接第三方的,其实如果你的分享要求不是很高,调系统的分享也是可以的。

一、思路:

用intent.action = Intent.ACTION_SEND

二、效果图:

在这里插入图片描述

三、关键代码:
 //这个是分享图片(相册中的图片)
            val path = FuFileUtils.addBitmapToAlbum(this, getDrawable(R.mipmap.head2)?.toBitmap());
            val intent = Intent(Intent.ACTION_SEND)
            intent.type = "image/*" //设置MIME类型
            intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path)) //需要分享的文件URI
            startActivity(Intent.createChooser(intent, "对话框标题"))
四、项目demo源码结构图:

在这里插入图片描述
有问题或者需要完整源码demo的可以看简介联系我,也可以私信我,我每天都看私信的