java是一种共享的方式*。json文件是通过Intent还是其他方式?
在我的应用程序中,我需要分享*。json文件到其他应用程序(messenger、google disk等)。我如何通过意图或其他方式做到这一点
但当我试图通过意图实现这一点时,我遇到了一些问题
override fun shareBackupData(path: String) {
val uri = Uri.parse(path)
val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
shareIntent.putExtra(Intent.EXTRA_STREAM, uri)
shareIntent.type = "*/*"
startActivity(Intent.createChooser(shareIntent, "Choose"))
}
当我运行这段代码时,我选择要共享的应用程序,然后我看到toast“不支持的附件”
# 1 楼答案
我也有类似的问题,我发现这个article建议我们使用^{}
它的作用是:
我建议你看看这篇文章,如果你想要代码,也可以看看这个Stackoverflow post
# 2 楼答案
我认为您可以将该文件用作ExtraStream。下面的代码是共享图像文件,您可以将其更改为json文件