PlatformFile. Call it from a source set that only includes Android and iOS, such as mobileMain (see shared source sets).
Usage
null when the user cancels. Failures go to onError in Compose, or are thrown as a FileKitDialogException by the suspend API. See Results and errors.
Options
FileKitCameraType
default:"Photo"
launch()
What to capture. Only
Photo is available: video capture is not supported yet.FileKitCameraFacing
default:"System"
launch()
System lets the camera app choose, or force Front or Back. Best effort on Android: see Platform notes.PlatformFile
default:"FileKit.cacheDir / \"<random UUID>.jpg\""
launch()
Where the photo is written. Files in
filesDir and cacheDir need no Android setup.FileKitOpenCameraSettings
default:"createDefault()"
rememberCameraPickerLauncher
Platform-specific settings. In the suspend API, pass it to
openCameraPicker().Keep the photo
The default destination is in the cache directory, which the system can clear. To keep the photo, write it toFileKit.filesDir directly:
FileKit.filesDir and FileKit.cacheDir need no Android setup. For any other directory, see Android setup.
Platform notes
Android setup
Only needed for files outsideFileKit.filesDir and FileKit.cacheDir. filekit-dialogs already ships a FileProvider (${applicationId}.FileKitFileProvider) that covers those two directories, and content:// files returned by the pickers need no provider at all. For any other location, such as getExternalFilesDir(), FileProvider throws an IllegalArgumentException until you declare your own provider.
1
Declare a provider in your manifest
AndroidManifest.xml
2
List the directories it may expose
Add one entry per location you use, for example app-specific external storage:See FileProvider for every path type.
res/xml/file_paths.xml
3
Pass the authority to FileKit
The
authority parameter exists only on Android, so build these settings in androidMain:androidMain
androidMain
openCameraSettings to rememberCameraPickerLauncher and the file to launch(destinationFile = ...).
Related
- Gallery picker to pick existing photos.
- Share file to send the photo to another app.
- Results and errors for cancellation and failure handling.