我下面的教程为建设一个相机应用 http://developer.android.com/工具/ device.html 以及我为我的呼吁Camera.open()返回null。我已经声明清单中的权限,我试图在模拟器和xyboard都和我仍然得到空。没有人知道任何快速提示吗?
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.
推荐答案
这是因为的它不应该抛出异常。它返回空
时,没有的回的-facing相机被找到:
That's because it's not supposed to throw an exception. It returns null
when no back-facing camera is found:
创建一个新的照相机对象来访问第一面对背面相机设备。如果设备不具有背对着摄像头,则返回null。
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.
您可能试图访问的前的-facing摄像头,在这种情况下,你可能想使用打开(INT cameraId)
。 (请参阅使用它的一个例子对方的回答)
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)
相关推荐
最新文章