Skip to content

Commit

Permalink
grant uri permission crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
toshanmugaraj committed Sep 17, 2024
1 parent fca16b6 commit 4762b80
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.activity.result.ActivityResultLauncher
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import im.vector.lib.core.utils.compat.queryIntentActivitiesCompat
import timber.log.Timber

/**
* Abstract class to provide all types of Pickers.
Expand Down Expand Up @@ -115,6 +116,14 @@ abstract class Picker<T> {
}
}
}
return selectedUriList.onEach { context.grantUriPermission(context.applicationContext.packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION) }
selectedUriList.forEach { uri ->
try {
context.grantUriPermission(context.applicationContext.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: SecurityException) {
// Handle the exception, e.g., log it or notify the user
Timber.w("Picker", "Failed to grant URI permission for $uri: ${e.message}")
}
}
return selectedUriList
}
}

0 comments on commit 4762b80

Please sign in to comment.