Added check if Android device has a camera

This commit is contained in:
dankito 2024-10-04 16:50:41 +02:00
parent 74d42abce3
commit 54e9a70122
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package net.codinux.banking.ui.service
import android.Manifest
import android.content.pm.PackageManager
import android.view.ScaleGestureDetector
import androidx.camera.core.*
import androidx.camera.lifecycle.ProcessCameraProvider
@ -30,7 +31,10 @@ actual object QrCodeService {
private val log by logger()
actual val supportsReadingQrCodesFromCamera = true
actual val supportsReadingQrCodesFromCamera = hasCamera()
private fun hasCamera(): Boolean = AndroidContext.applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)
@Composable
actual fun readQrCodeFromCamera(resultCallback: (QrCodeReadResult) -> Unit) {