android camera in background

2020-02-06 09:55发布

问题:

I am developing an application to take images from background application say using android service. i don't want any user interaction to takes images, it should completely work from background.

I have already tried -

  1. Calling camera from service - It not always works sometime works if we have dummy surfaceview, again if Android close the related activity service stopped takings pics, I don't want to run activity for user interaction. with some changes it working fine but all images are black.
  2. Widget: Not getting how to call camera in widget as widget doesn't support surfaceview.
  3. Live wallpaper: not able to make it work till now, does it supports for camera?

As per my experience till now Android camera service not designed to takes picture if no real preview available.

Is anyone developed something like this? any help will be really appreciate.

回答1:

If you can ignore older versions, it may be easier to use SurfaceTexture (API 11 and higher) As vikky.rk notes in an answer to a recent question, an introduction to this technique can be found in the PanoramaActivity code of the default Android Camera App.