分享多个文件到whatsApp

在分享前,先创建一个ArrayList用来存储需要分享文件的Uri,必须是content://类型的

然后

            var intent = Intent()
            intent.setAction(Intent.ACTION_IMAGE_CAPTURE)
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris)
            intent.setPackage("com.whatsapp")
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            intent.addCategory("android.intent.category.DEFAULT")
            val type = intent.type
            intent.setType("audio/*")
            try {
                startActivity(Intent.createChooser(intent,                 
            mContext!!.getResources().getString(R.string.shareRecord_titleName)))
            } catch (e: Exception) {
                e.printStackTrace()
            }

其中fileUris为我们存数Uri的ArrayList

MediaStore.ACTION_IMAGE_CAPTURE

intent.putParcelableArrayListExtra(,)可以分享多个文件

intent.putExtra(Intent.EXTRA_STREAM,uri)可以分享单个文件

你可能感兴趣的:(分享多个文件到whatsApp)