Overview
TTakePhotoFromCameraAction and TTakePhotoFromLibraryAction still function in Delphi's FMX layer, but the underlying platform APIs they rely on have changed significantly. Several behaviors that worked in 2018 are broken or deprecated on Android 13+ and iOS 14+.
Background
Android Changes
- Android 11+ (API 30): Camera intents must use a
FileProvider URI, not a bare file:// URI. Delphi 13's FMX runtime handles this internally, but any custom camera code using direct paths will throw FileUriExposedException.
- Android 13 (API 33): The new Photo Picker (
ACTION_PICK_IMAGES) is the recommended replacement for ACTION_OPEN_DOCUMENT and gallery intents. It does not require any READ_MEDIA_IMAGES permission.
- Camera permission: Still required for
TTakePhotoFromCameraAction.
iOS Changes
- iOS 14:
PHPickerViewController replaced the old UIImagePickerController for photo library access. Delphi's FMX TTakePhotoFromLibraryAction wraps the native picker — verify that Delphi 13's implementation uses PHPickerViewController.
- iOS 14 Limited Photo Library Access: Users can grant access to selected photos only rather than the full library. Apps must handle the
.limited authorization status gracefully.
- iOS 16+:
UIImagePickerController for camera is deprecated (but still works); AVFoundation is now preferred for custom camera UIs.
Current Code Pattern
In uNewEntryFrame.pas, the code calls TTakePhotoFromCameraAction and TTakePhotoFromLibraryAction actions and handles the OnDidFinishTaking event. The TBitmap result is scaled to max 1024×512 and stored. This flow needs verification against Delphi 13's updated FMX media library actions.
Files Affected
lab-src/Lab05.../frames/uNewEntryFrame.pas
lab-src/Lab06.../frames/uNewEntryFrame.pas
... (Lab05 through Lab12)
lab-src/Lab*/forms/formMain.pas (action wiring)
Steps to Address
- Verify that Delphi 13's
TTakePhotoFromCameraAction correctly uses a FileProvider URI on Android — test on API 30+ emulator.
- Verify that
TTakePhotoFromLibraryAction uses PHPickerViewController on iOS 14+ — check Delphi 13 release notes or FMX source.
- Add handling for iOS limited photo library authorization status: if the user grants limited access, inform them rather than silently failing.
- Test image resize logic (max 1024×512) still functions correctly with the bitmap returned by the updated actions.
- Ensure the
android.permission.CAMERA runtime request uses System.Permissions.RequestPermissions (not raw JNI) consistently.
- Update lab instructions to explain the Photo Picker flow for Android 13+ and limited library access on iOS 14+.
Test Plan
Overview
TTakePhotoFromCameraActionandTTakePhotoFromLibraryActionstill function in Delphi's FMX layer, but the underlying platform APIs they rely on have changed significantly. Several behaviors that worked in 2018 are broken or deprecated on Android 13+ and iOS 14+.Background
Android Changes
FileProviderURI, not a barefile://URI. Delphi 13's FMX runtime handles this internally, but any custom camera code using direct paths will throwFileUriExposedException.ACTION_PICK_IMAGES) is the recommended replacement forACTION_OPEN_DOCUMENTand gallery intents. It does not require anyREAD_MEDIA_IMAGESpermission.TTakePhotoFromCameraAction.iOS Changes
PHPickerViewControllerreplaced the oldUIImagePickerControllerfor photo library access. Delphi's FMXTTakePhotoFromLibraryActionwraps the native picker — verify that Delphi 13's implementation usesPHPickerViewController..limitedauthorization status gracefully.UIImagePickerControllerfor camera is deprecated (but still works);AVFoundationis now preferred for custom camera UIs.Current Code Pattern
In
uNewEntryFrame.pas, the code callsTTakePhotoFromCameraActionandTTakePhotoFromLibraryActionactions and handles theOnDidFinishTakingevent. TheTBitmapresult is scaled to max 1024×512 and stored. This flow needs verification against Delphi 13's updated FMX media library actions.Files Affected
Steps to Address
TTakePhotoFromCameraActioncorrectly uses aFileProviderURI on Android — test on API 30+ emulator.TTakePhotoFromLibraryActionusesPHPickerViewControlleron iOS 14+ — check Delphi 13 release notes or FMX source.android.permission.CAMERAruntime request usesSystem.Permissions.RequestPermissions(not raw JNI) consistently.Test Plan
FileUriExposedExceptionis thrown when capturing a photo.PHPickerViewController.