Choose selection rather than collection access
A picker is appropriate when the user chooses specific items. A full gallery-management application may have different needs, but “upload one image” is not a strong reason to request access to every image on the device.
Follow the Photo Picker documentation for current AndroidX contracts, availability and fallback behavior. Do not hardcode assumptions about which picker UI every device will display.
Handle the result as a URI
This activity or fragment fragment illustrates the single-image flow:
private val chooseImage = registerForActivityResult(
ActivityResultContracts.PickVisualMedia()
) { uri ->
if (uri != null) importSelectedImage(uri)
}
// Called after the user chooses “Attach photo”.
chooseImage.launch(
PickVisualMediaRequest(
ActivityResultContracts.PickVisualMedia.ImageOnly
)
)
The helper must validate and stream the content safely. Cancellation returns no selection and should not display an error or start an upload.
Do not turn the URI into a guessed path
Use ContentResolver to open selected content. The provider may serve remote or virtual media. Bound memory use, handle unavailable content and avoid assuming that the filename extension proves the format.
For deferred uploads, follow the documented access-lifetime and persistable-permission rules for the returned URI. Do not assume a temporary grant survives every app or device lifecycle event.
Test real edge cases
Test cancellation, a large image, a remote provider, selected media becoming unavailable and repeated selection. Confirm that the upload does not start before the user chooses the item and that the UI reports progress and failure accurately.
Remove unnecessary broad requests
Review the media access model and the merged release manifest after migration. APKLint's Dangerous Permissions Checker can help identify old storage declarations left behind by the app or SDKs. It cannot verify URI lifetime or image-processing memory behavior; those need runtime tests of the actual import flow.
Sources and further reading
Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.



