Simple camera app for android using camerax lib.
build.gradle
project level
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
build.gradle
app level
implementation 'com.github.saugatrai33:EvolveCamera:2.0.6'
class MainActivity : AppCompatActivity() {
private lateinit var image: ImageView
private val evolveActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
val photoUri: Uri? = result.data?.data
if (photoUri != null) {
imageUri = photoUri
showImage()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
image = findViewById(R.id.image)
EvolveImagePicker.with(this)
.start(evolveActivityResultLauncher)
}
private val evolveActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
val data = result.data!!.data
Log.d("MainActivity::", "result: ${data.toString()}")
Glide.with(this)
.load(data)
.apply(RequestOptions.centerCropTransform())
.into(image)
}
}
EvolveImagePicker
.with(requiredActivity())
.start(evolveActivityResultLauncher)
EvolveImagePicker
.with(this)
.start(evolveActivityResultLauncher)
private val evolveActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
val data = result.data!!.data
Log.d("MainActivity::", "result: ${data.toString()}")
Glide.with(this)
.load(data)
.apply(RequestOptions.centerCropTransform())
.into(image)
}
[https://developer.android.com/reference/android/graphics/ImageFormat] Supported image format depends upon device.