Access Camera and Gallery in a Jetpack Compose Android App

Charles Raj Iruthayaraj
3 min readJul 24, 2024

Hello Buddy’s

In this blog, we’ll explore how to access images from the gallery and use the system camera to take pictures in an Android application using Kotlin. This tutorial builds upon a previous example where we demonstrated creating a bottom navigation with a FAB (Floating Action Button). We’ll integrate camera and gallery access into this application.

Adding Permissions

First, we need to add the necessary permissions in the AndroidManifest.xml file. These permissions allow the app to access the camera and the gallery. and we’ll add the content provider authorities and file path to store the image in the content provider.

<manifest ...>
<application ...>
...
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
</manifest>

--

--

Charles Raj Iruthayaraj
Charles Raj Iruthayaraj

Written by Charles Raj Iruthayaraj

Experienced software developer with hands-on experience in Android application and iOS development. https://preply.com/en/tutor/5664578