when initialising camera hardware and binding, we check if camera are available and the throw exception if not, we can observe it in the following peace of code:
lensFacing = when {
hasBackCamera() and !options.isFrontFacing -> CameraSelector.LENS_FACING_BACK
hasFrontCamera() and options.isFrontFacing -> CameraSelector.LENS_FACING_FRONT
else -> throw IllegalStateException("Back and front camera are unavailable")
}
The main issue with this code is that this case actually happened on a moto g power (android 11) and the exception is thrown which is well anticipated code. But the exception is not handled and not delegated causing the application to crash. Here is what I propose in the PR:
Delegate exception to fragment
@Throws(IllegalStateException::class)
fun bindCameraUseCases(binding: FragmentPixBinding) {
Handle exception in fragment by backpressing and return to the previous view
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi,
when initialising camera hardware and binding, we check if camera are available and the throw exception if not, we can observe it in the following peace of code:
The main issue with this code is that this case actually happened on a moto g power (android 11) and the exception is thrown which is well anticipated code. But the exception is not handled and not delegated causing the application to crash. Here is what I propose in the PR:
Also work for another thrown in the same function.
Regards 73k05