Hadi
Hadi

Reputation: 33

Using Camera without preview or surface in android

I was looking for a method to use the camera on android devices without a surfaceview or a preview. I found out that, it is impossible to take picture without that preview. However, I have found a tutorial which is actually working taking pictures without a preview. Here is the link: http://www.vogella.com/articles/AndroidCamera/article.html

After switching the camera in the code from front to back-facing the app didn't crashed but it gave me an error 100. So it is only working with the front cam at the moment.

I am using a Samsung Galaxy S3(4.1.2) and i will test it on a Galaxy S2 and a Galaxy S3 Mini.

Anyone a good explanation for this?

Upvotes: 1

Views: 5377

Answers (2)

Mir Saman
Mir Saman

Reputation: 153

Actually the time interval of question and answer is large, but may help others.

You can try this library to take picture even from service:

https://github.com/kevalpatel2106/android-hidden-camera

It uses a feature to draw over other apps and create a fake surface. Hope it helps.

Upvotes: 1

Eddy Talvala
Eddy Talvala

Reputation: 18107

You cannot take a picture without starting preview.

While some Android devices are more flexible, and allow takePicture to be called without preview running, this is technically against the API specifications.

It won't work on a large number of devices, so please don't rely on it. That tutorial is wrong, and presumably tested only on one of the devices that allows this behavior.

If you don't want a visible preview, see this question for ways to do that in Android versions >= 3.0.

Upvotes: 1

Related Questions