Taking picture from non-activity

前端 未结 3 856
时光取名叫无心
时光取名叫无心 2021-01-02 22:23

I am using dummy surface in my code.It\'s working fine in Canvas HD running 4.2.1 but when the same app is deployed on my nexus 5/S 3 it gives RunTimeException on camera.tak

3条回答
  •  北海茫月
    2021-01-02 23:10

    You shouldn't use a dummy SurfaceView as Android checks is the SurfaceView is displayed on the screen.

    Instead, display the preview on a SurfaceView with WindowManager, with type SYSTEM_OVERLAY. Set your SurfaceView width and height to 1px and the opacity to 0 to hide the preview, and that's it!

    If you plan to support only 5.0+ devices, or it's a new app that won't be available too soon, you should consider using the new android Camera2 API, which fixed many mistakes of the older API.

    Hope it will help you :)

提交回复
热议问题