Created
September 7, 2025 10:35
-
-
Save root-ansh/a248d60d6f50b9d6d80ebad07378ff7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { | |
| type = "image/*" //"application/pdf" // "*/*" | |
| putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/*")) // required in some android versions. also good if you set type as */* and want to filter mimetypes | |
| addCategory(Intent.CATEGORY_OPENABLE) | |
| addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION)// optional for our app, but required if you intend to save the SAF content uris(temporary by nature) in databases | |
| } | |
| getFileFromSystem.launch(intent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment