How to use Camera to take picture in a background

2019-01-14 13:33发布

问题:

This question already has an answer here:

  • Taking picture from camera without preview 9 answers

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?

I found various contrastants answers on web...

How can I do it?

回答1:

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);


回答2:

It's not possible without the preview / surface view.