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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With