I have a function to take pictures that goes like this:
private fun takePicture() {
Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
takePictureIntent.resolveActivity(packageManager)?.also {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE)
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val imageBitmap = data?.extras?.get("data") as Bitmap
val mediaStorageDir = File(Environment.getExternalStoragePublicDirectory("Pics"), "CameraApp")
val file: File("path/image.jpg")
val outputStream = FileOutputStream(file)
imageBitmappress(Bitmap.CompressFormat.JPEG, 100, outputStream)
outputStream.close()
}
The problem is this way I have two moments, the "taking picture" and the "accepting taken picture", as you can see below:
How do I avoid this "second moment" and send the user directly to another activity where he'll be able to accept the photo and do other stuff with it? If you have any other suggestion on how to do this or think I should change the way the picture is being taken I'd like to hear too.