0
votes

I'm setting up camera app. There are functions like "capture" "rotate camera" "gallery" "back" etc. Application is running on emulator include all functions, but on real device, "capture" and "rotate camera" not working.

I have already tried the Instant Run - Clean & Rebuild App

MainActivity

camera.captureImage { camera, capturedImage ->
            val savedPhoto = File(Environment.getExternalStorageDirectory(), "photo.jpg")
            try {
                val outputStream = FileOutputStream(savedPhoto.path)
                outputStream.write(capturedImage)
                outputStream.close()
            } catch (e: java.io.IOException) {
                e.printStackTrace()
            }
            //capturedImage converted to bitmap
            var bitmap: Bitmap = BitmapFactory.decodeByteArray(capturedImage, 0, capturedImage.size)
            capturedImageView.setImageBitmap(bitmap)
            capturedImageView.visibility=View.VISIBLE

I expect the applications all functions run in both emulator and real device which is General Mobile 5 Plus

1
Do you get any errors, crashes, log messages?eleven
only this : Access denied finding property "persist.camera.cfa.packagelist"brkcnplt

1 Answers

0
votes

Hope you are using Camera2 and not just Camera. And provide below permissions too when using Camera2.

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera2.full" />
<uses-feature android:name="android.hardware.camera2.autofocus" />