Camera API working on Jelly Bean but not Kitkat

后端 未结 3 537
自闭症患者
自闭症患者 2020-12-30 13:55

I have a really strange problem. The following code I have is used to take a picture on button click. It works properly on Jelly Bean phones, but not on Kitkat:

3条回答
  •  甜味超标
    2020-12-30 14:29

    I have observed that you are not assigning any surface holder to the camera. Giving a preview surface to the camera is important.

    According to the docs here:

    http://developer.android.com/guide/topics/media/camera.html

    follow the code suggested by the doc. Taking a picture without a preview is a big security concern. Android guys might have fixed this in kitkat.

    You might have missed that part of the code while pasting here so as an added concern also check that you are executing your code 'camera.takePicture(null,null,callback)' inside the callback method 'onSurfaceCreated' of SurfaceHolder.

    You can get all the relevant code at aforementioned link.

提交回复
热议问题