Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [Unreleased]

### 2026-10-14

- Fix: catch the `SecurityException` thrown by `takePersistableUriPermission` in `IONCAMROpenPhotoPickerActivity` when the picker returns a URI without a persistable grant (seen on Android 11/12), so choosing from the gallery no longer crashes the app ([capacitor-camera#58](https://github.com/ionic-team/capacitor-camera/issues/58)).

## [1.0.2]

### 2026-07-08
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ class IONCAMROpenPhotoPickerActivity : ComponentActivity() {

private fun makeUriPermissionPersistable(uri: Uri) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // only for Android >= 11
applicationContext.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
try {
applicationContext.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: SecurityException) {
// Some pickers (GMS-backported photo picker, OEM galleries on Android 11/12) hand back
// URIs with no persistable grant; the temporary read grant is enough to process the media.
Log.w("PhotoPicker", "Could not persist URI permission for $uri", e)
}
}
}

Expand Down