问题
I am developing an Android security app, and I want to capture images in background without preview. Is it possible to capture images in the background using the camera2 api?
回答1:
Yes, but as of Android 5.0 Marshmallow, you may be disconnected from the camera at any time, if a foreground app wants to use it instead.
And before Android M, using the camera from the background is not recommended, since you'll block any foreground app from using it (the app will just get an error trying to open the camera, and generally will crash as a result).
Otherwise, the camera API works the same. You'll need to run the camera for a few seconds before taking the final picture to ensure metering and focus are generally good, though exactly what you need would depend highly on the details of your use case.
来源:https://stackoverflow.com/questions/36770168/how-to-capture-images-in-background-using-camera2-api