3

I am following the tutorial for building a camera app http://developer.android.com/tools/device.html and I am my call to Camera.open() returns null. I've declared the permission in the manifest and I tried both on the emulator and a xyboard and I am still getting null. Does anyone know any quick hints?

Camera c = null;
try
{
    c = Camera.open()
}
catch(Exeption e)
{

}
return c;

Keep in mind, I am not throwing an exception, I am simply getting NULL back.

1
  • Check logcat, SOMETHING is happening. Also camera implementation is different for different devices and OS levels, need more information. Commented Sep 25, 2012 at 16:15

3 Answers 3

4

That's because it's not supposed to throw an exception. It returns null when no back-facing camera is found:

Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null.

You may be trying to access a front-facing camera, in which case you probably want to use open(int cameraId). (See the other answer for an example of using it)

Sign up to request clarification or add additional context in comments.

Comments

2

Here is a really great tutorial for working with the android camera
You'll notice thru out the code there are toasts/alerts that will help guide you to what is happening

Comments

0

In order to get this working, I had to use the Camera.open(0) which meant that I had to change the API level in the manifest from 8 to 9. I am now getting an Error 100 though...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.