How to fix “Fail to connect to camera service” exception in Android emulator

前端 未结 8 1689
情书的邮戳
情书的邮戳 2020-12-01 06:35

I\'m getting a Fail to connect to camera service exception when I run my Android app in the emulator. I\'ve read the various existing posts but none have fixed this. It is

8条回答
  •  误落风尘
    2020-12-01 06:50

    Using

    if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
      ActivityCompat.requestPermissions(CodeScanner.this, new String[]{android.Manifest.permission.CAMERA}, 50);
    }
    

    worked for me

提交回复
热议问题