views:

549

answers:

2

I am writing an android 1.5 application which starts just after boot-up.
This is a service and should take a picture without preview. This app will log the light density in some areas whatever. I was able to take a picture but the picture was black.

After googling like crazy, i came across a bug thread about it. If you don't generate a preview, the image will be black since android camera needs preview to setup exposure and focus. I've created a surfaceview and listener but the onSurfaceCreated event never gets fired.

I guess the reason is, the surface is not being created visually. I've also seen some examples of calling the camera statically with MediaStore.CAPTURE_OR_SOMETHING which takes a picture and saves in the desired folder with two lines of code but it doesn't take a picture too.

Do i need to use ipc and bindservice to call this function or do you have any suggestion to achieve my goal (taking a picture without preview) and if so, would you give me a small piece of code as example?

+1  A: 

This is a service and should take a picture without preview.

That is not possible, AFAIK.

I've created a surfaceview and listener but i the onSurfaceCreated event never gets fired. I guess the reason is, the surace is not being created visually.

Correct.

do you have any suggestion to achieve my goal (taking a picture without preview)

Again, it is not possible, AFAIK.

CommonsWare
A: 

it is really weird that camera on android platform can't stream video until it given valid preview surface. it seems that the architects of the platform was not thinking about 3rd party video streaming applications at all. even for augmented reality case the picture can be presented as some kind of visual substitution, not real time camera stream.

anyway, you can simply resize preview surface to 1x1 pixels and put it somewhere in the corner of the widget (visual element). please pay attention - resize preview surface, not camera frame size.

of course such trick does not eliminate unwanted data streaming (for preview) which consumes some system resources and battery.

alexander.o.krutyakov