0

Can I take a picture from an IntentService in Android without displaying a preview surface to the user?

I have tried:

SurfaceView view = new SurfaceView(this);
c.setPreviewDisplay(view.getHolder());
c.startPreview();
c.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);

But it doesn't work on my phone, Galaxy S2X

  • Thanks for your reply but can you elaborate a bit? I've seen several articles trying to allow services to take pictures but I haven't been able to get my phone Galaxy S2X to work with it. – user2712354 Oct 13 '14 at 01:08
  • You might find [this](http://stackoverflow.com/questions/2386025/android-camera-without-preview/) question useful. – Andrew T. Oct 13 '14 at 01:49

1 Answers1

0

You can record video without live preview, see e.g. https://stackoverflow.com/a/14997460/192373. You can force this recording to contain one frame if you wish. You can not capture a still photo without a View. Note that on some devices this restriction is not enforced, and in any case there are write a few known workarounds that make the live preview invisible to the end-user. Here you can find an answer how you can create a view from a background service.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307