Jetpack-CameraX is simplest way to click and pick image.
JetPack-CameraX helps you add reliable camera to your app quickly. It use cameraX library inside.Simple implementation.Check out apk.
-
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } } -
Step 2. Add the dependency
Add it in your app module build.gradle:
dependencies { ... implementation 'com.github.SaeculumSolutions:Jetpack-CameraX-Android:1.0.0' }
-
Step 1. Add JetPackCameraX in to your activity class:
val intent = JetPackCameraX(this).build() /* * if you want open front camera as default use this * val intent = JetPackCameraX(this).setCameraLensFacingFront(true).build() */ startActivityForResult(intent, LAUNCH_CAMERA_X_ACTIVITY)
-
Step 2. override onActivityResult function to get JetPackCameraX result.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (resultCode == Activity.RESULT_OK && data != null) { when (requestCode) { LAUNCH_CAMERA_X_ACTIVITY -> { if (data != null) { val path: String = data.extras?.get(CameraXImage.GET_CLICKED_IMAGE_URI).toString() Log.d(TAG, "onActivityResult: $path" ) // Do needful with your selectedMedia } } } } }
It would be great for us if the reporter can share the below things to understand the root cause of the issue.
- Library version
- Code snippet
- Logs if applicable
- Device specification like (Manufacturer, OS version, etc)
- Screenshot/video with steps to reproduce the issue
- minSdkVersion >= 21
- Androidx
def camerax_version = '1.0.0-rc01'
implementation "androidx.camera:camera-core:$camerax_version"
// CameraX Camera2 extensions
implementation "androidx.camera:camera-camera2:$camerax_version"
// CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:$camerax_version"
// CameraX View class
implementation 'androidx.camera:camera-view:1.0.0-alpha20'-dontwarn com.bumptech.glide.**
JetPack-CameraX is Apache License 2.0.
We’d be really happy if you send us links to your projects where you use our component. Just send an email to info@saeculumsolutions.com And do let us know if you have any questions or suggestion regarding our work.





