Skip to content

Commit e34eb24

Browse files
committed
Change intent type from open document to get content
1 parent ef62d75 commit e34eb24

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@ Where `$libVersion`
6060
if (it.resultCode == Activity.RESULT_OK) {
6161
val uri = it.data?.data!!
6262
// Use the uri to load the image
63-
}
64-
}
63+
// Only if you are not using crop feature:
64+
uri?.let { galleryUri ->
65+
contentResolver.takePersistableUriPermission(
66+
uri, Intent.FLAG_GRANT_READ_URI_PERMISSION
67+
)
68+
}
69+
//////////////
70+
}
71+
}
6572
```
6673

6774
**Java**

imagepicker/src/main/kotlin/com/github/drjacky/imagepicker/util/IntentUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object IntentUtils {
4141
*/
4242
private fun getGalleryDocumentIntent(mimeTypes: Array<String>): Intent {
4343
// Show Document Intent
44-
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).applyImageTypes(mimeTypes)
44+
val intent = Intent(Intent.ACTION_GET_CONTENT).applyImageTypes(mimeTypes)
4545
intent.addCategory(Intent.CATEGORY_OPENABLE)
4646
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
4747
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

0 commit comments

Comments
 (0)