应用程序的功能在模拟器上运行,但不在真实设备上运行

时间:2019-09-05 11:58:16

标签: android android-studio android-emulator

我正在设置相机应用。有诸如“捕获”,“旋转照相机”,“图库”,“后退”等功能。正在模拟器上运行的应用程序包含所有功能,但在实际设备上,“捕获”和“旋转照相机”不起作用。

我已经尝试过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

我希望应用程序的所有功能都可以在仿真器和实际设备(通用移动5 Plus)中运行

1 个答案:

答案 0 :(得分:0)

希望您使用的不是Camera,而是Camera2。并在使用Camera2时也提供以下权限。

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