android 相机(froyo)不包含静态方法 open()
我一定是第一个面对这个问题的人,因为我什至找不到关于它的任何线索。
今天我想从我的应用需求的相机方面开始。 我阅读了一些文档,
我的清单如下所示:
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
我在
上方和
下面的清单中写了这个,
我正在做的是;我创建了一个新班级。 使用 eclipse 作为我的 IDE。
然后我声明一个字段:
Camera _camera;
在构造函数中(只是为了测试) 我尝试这样做:
_camera = Camera.open();
我收到错误。 我使用真实的手机来测试该应用程序,因为我没有网络摄像头或任何可供模拟器使用的东西。当我告诉模拟器有一个摄像头时,模拟器给我一个内存错误。
不管怎样,在发现为什么我不能使用Camera.open(我包含了包:android.graphics.Camera;)后,因为这就是当我用来组织导入功能时eclipse为我包含的内容。
我查看了 eclipse 为我附加的 android.jar。包含在名为 Android 2.2 -> 的文件夹中android.jar
我搜索了 android.graphics 并查看了 Camera.class 的内容 结果
发现我的 Camera 类只有这些方法:
Camera()
applyToCanvas()
dotWithNormal()
finalize()
getMatrix()
restore()
rotateX()
rotateY()
rotateZ()
save()
translate()
我故意把参数放出来,因为它们不重要。
回答实际问题:为什么?
为什么没有open()方法,没有release()方法?以及我缺少的其他内容......'
感谢您的阅读。
今天的课程:不要做一个聪明的**。我确实 950% 确定我包含了那个特定的包。但这是错误的包裹。德普。谢谢你通知我。问题解决了。
I must be the first to face this problem because I can't find even a single thread about it.
Today I wanted to start on the camera aspect of my application needs.
I read up some documentation
my manifest looks like this:
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
I wrote this in the manifest ABOVE <application>
and underneath <manifest>
What im doing is; I have created a new class.
using eclipse as my IDE.
I then declare a field:
Camera _camera;
In the constructor(just to test)
I tried to do:
_camera = Camera.open();
I got an error.
I use my real phone to test the app, because I have no webcam or anytihng for the simulator to use. And the simulator gives me a memory error when I tell it to have a camera.
Anyway, upon finding out why I can't use Camera.open (I included the package: android.graphics.Camera;) Because that is what eclipse included for me when i used to organize imports function.
I looked into the android.jar that eclipse attached for me. Contained in a folder thingy called Android 2.2 -> android.jar
I searched for android.graphics and took a peek in the content of Camera.class
It turns out that my Camera class only has these methods:
Camera()
applyToCanvas()
dotWithNormal()
finalize()
getMatrix()
restore()
rotateX()
rotateY()
rotateZ()
save()
translate()
I intentionally let the parameters out because they are of no importance.
To get to the actual question: Why?
Why is there no open() method, no release() method? and whatever else im missing.. '
Thanks for reading.
Todays lesson: Don't be a smart **s. I was indeed 950% sure I included that specific package. But it was the wrong package. derp. Thanks fo notifying me. Issue is solved.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用了错误的相机。
android.graphics.Camera - 相机实例可用于计算 3D 变换并生成可应用于画布等的矩阵。
android.hardware.Camera - Camera 类用于设置图像捕获设置、开始/停止预览、抓拍图片以及检索用于视频编码的帧。此类是相机服务的客户端,它管理实际的相机硬件。
You are using the wrong Camera.
android.graphics.Camera - A camera instance can be used to compute 3D transformations and generate a matrix that can be applied, for instance, on a Canvas.
android.hardware.Camera - The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.
您使用了错误的 Camera 类。使用这个 http://developer.android.com/reference/android/hardware/ Camera.html
您正在使用 android.graphics.Camera 中的相机,我想您需要 android.hardware.Camera 中的相机
You are using a wrong Camera class. Use this one http://developer.android.com/reference/android/hardware/Camera.html
You are using Camera from android.graphics.Camera I suppose you need the one from android.hardware.Camera
您正在寻找
android.hardware.Camera
。You are looking for
android.hardware.Camera
.