・symptom
The app is using zxing 1.9 for QR code reading.
It works well in almost android devices, but dose not work well in Galaxy S9 and S9+ devices.
It seems like auto focus is not working.
Upto Galaxy version 8, no problem.
・environment
Android : 5 to 8.0
Kernel ver : 4.9.65-144892203
zxing : 1.9 version
Device : Galaxy S9 , Galaxy S9+
I solve the issue with following code. Working well with Galaxy S8, S8+, S9, S9+.
private val autoFocusExecutor = ScheduledThreadPoolExecutor(1)
fun startCamera() {
if (camera == null) {
camera = Camera.open()
if (camera == null) {
showCameraErrorMsg()
} else {
preview.camera = camera
capturereceipt_textview_cameraerrormsg.visibility = View.GONE
capturereceipt_framelayout_viewfinder.visibility = View.VISIBLE
autoFocusExecutor.schedule(Sc{
val params: Camera.Parameters = camera!!.parameters
if (params.getSupportedFocusModes()
.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
//TODO: Auto focus not working
params.focusMode = Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE
}
camera?.parameters = params
}, 1000, TimeUnit.MILLISECONDS)
}
}}