Camera.open()返回NULL Android开发 [英] Camera.open() returns NULL Android development

查看:2334
本文介绍了Camera.open()返回NULL Android开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的教程为建设一个相机应用 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)

这篇关于Camera.open()返回NULL Android开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆