Failed to connect to camera service

前端 未结 10 2042
梦毁少年i
梦毁少年i 2020-11-28 10:13

I\'m trying to access the camera on my phone. I\'m writing a simple stub app prior to putting the code in a widget. I\'m not getting very far. The code always throws a runti

10条回答
  •  醉酒成梦
    2020-11-28 11:04

    Few things:

    1. Why are your use-permissions and use-features tags in your activity tag. Generally, permissions are included as direct children of your tag. This could be part of the problem.

    2. According to the android camera open documentation, a runtime exception is thrown:

      if connection to the camera service fails (for example, if the camera is in use by another process or device policy manager has disabled the camera)

      Have you tried checking if the camera is being used by something else or if your policy manager has some setting where the camera is turned off?

    3. Don't forget the for autofocus.

    While I'm not sure if any of these will directly help you, I think they're worth investigating if for no other reason than to simply rule out. Due diligence if you will.

    EDIT As mentioned in the comments below, the solution was to move the uses-permissions up to above the application tag.

提交回复
热议问题