How to take pictures from the camera without preview when my app starts?

前端 未结 5 708
南方客
南方客 2020-12-01 02:00

Now all I want is an app that just takes the picture from the camera upon launching. No layout, no camera preview...nothing, just a simple app icon to launch the app. Once l

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 02:26

    I've tried exactly what you need before and after alot of research found out that for some reason you must have a preview started and even showing that content in a SurfaceView to be able to get the picture, apparently the system behind the scenes flushes whatever is in the buffer for the SurfaceView rendering the preview, now what I did to overcome this issue (taking the picture without preview) was just to set the SurfaceView in my layout to 1dp width and 1dp height (notice it has to be 1dp, 0dp will cause a crash).

    
    

    It definitely might not be a very elegant way to get rid of the "preview" Image but it definitely does the trick and left me room to do everything else I had in mind.

    Hope this helps...

    Regards

提交回复
热议问题