我正在尝试与 android 中的第三方应用程序共享图像。我可以与除小米(Android 12)和一加节点(Android 11)以外的所有设备共享图像。
val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
shareIntent.putExtra(Intent.EXTRA_TEXT, shareText)
shareIntent.putExtra(Intent.EXTRA_STREAM,imageUri)
shareIntent.type = "image/*"
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
context.startActivity(Intent.createChooser(shareIntent, "Share using"))
显示 toast 消息 --> 不支持此文件。
最佳答案
val file = File(path, "${System.currentTimeMillis()}.png")
file.outputStream().use {
imageBitmap!!.compress(Bitmap.CompressFormat.PNG,100, it)
}
var imageUri = FileProvider.getUriForFile(
context,
BuildConfig.APPLICATION_ID + ".fileprovider",
file )
关于android - 将图像分享到 android 中的第三方应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73049740/