开发者

android camera (froyo) doesnt include static method open()

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="and开发者_如何转开发roid.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.


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.


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


(yes im 950% sure I have included the package: android.graphics.Camera;)

You are looking for android.hardware.Camera.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜