[英]AutoFocus is not working on Galaxy S9 and S9+ with Zxing library
·症狀
該應用程序正在使用zxing 1.9進行QR碼讀取。
它在幾乎android設備上都能很好地工作,但在Galaxy S9和S9 +設備上不能很好地工作。
似乎自動對焦無法正常工作。
直到Galaxy版本8,沒問題。
·環境
Android:5至8.0
內核版本:4.9.65-144892203
zxing:1.9版本
設備:Galaxy S9,Galaxy S9 +
我用以下代碼解決了這個問題。 與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)
}
}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.