'How do i know a specific mime type for Android SAF?
I'd like to save a file of my custom type (let's say .asf
) using Android Storage Access Framework's ACTION_CREATE_DOCUMENT. What mime type should i pass to be supported at least default Android File manager and save on file storage? How about some more common extensions (eg. .hex
)?
If i don't pass a type
at all:
fun saveFile(fromFile: File, fileName: String, mimeType: String, resultCode: Int) {
inputFile = fromFile
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
if (mimeType.isNotEmpty()) {
type = mimeType
}
putExtra(Intent.EXTRA_TITLE, fileName)
}
context.startActivityForResult(intent, resultCode)
}
i'm getting:
android.content.ActivityNotFoundException, No Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] (has extras) }, , null)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|