In my case I had to use MediaStore.ACTION_IMAGE_CAPTURE
in order to disable selecting image from the phone gallery.
In order to achieve "similar" behaviour with taking several pictures I was starting next camera intent directly from onActivityResult
while processing recently taken photo in background.
Code looks like this:
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != REQUEST_IMAGE_CAPTURE) {
return
}
if (resultCode == Activity.RESULT_CANCELED) {
Timber.d("Taking image was cancelled")
return
}
if (resultCode == Activity.RESULT_OK) {
lastTakenPhotoData?.let {
handlePhotoTaken(it)
startCameraIntent()
}
}
}
...
private fun handlePhotoTaken(...) {
disposable.add(
Single.fromCallable { compressPhotoTaken(data) }
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()).subscribe { _ ->
//update UI with processed photo
}
)
}
...
private fun compressTakenPhoto(...) {
//rotate, compress, save taken photo to the local file if needed
//this part was taking quite a lot of time, so it is better to do it in background
}