java 如何使用相机在 Android 的后台服务中拍照?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7398897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use Camera to take picture in a background Service on Android?
提问by Lork
I'm developing a Service, running in background, that uploads succesfully images and data to the web.
我正在开发一个在后台运行的服务,它可以成功地将图像和数据上传到网络。
Now I want to upload an image taken by the Camera.
现在我想上传相机拍摄的图像。
Is it possible to use the camera in a background service without preview on Android 2.2?
是否可以在 Android 2.2 上不预览的情况下在后台服务中使用相机?
I found various contrastants answers on web...
我在网上找到了各种对比答案...
How can I do it?
我该怎么做?
采纳答案by Michele
You can take pictures without preview with an dummy view.
您可以使用虚拟视图在不预览的情况下拍照。
like:
喜欢:
SurfaceView view = new SurfaceView(this);
c.setPreviewDisplay(view.getHolder());
c.startPreview();
c.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);
回答by Mathias Conradt
It's not possible without the preview / surface view.
没有预览/表面视图是不可能的。