1

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.

Joey Roosing
  • 2,145
  • 5
  • 25
  • 42

3 Answers3

3

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.

Ilya Saunkin
  • 18,934
  • 9
  • 36
  • 50
  • 1
    Words can't describe how much I love you. Furthermore, they also can't describe how lame that mistake is. To the corner with me. – Joey Roosing Sep 23 '11 at 10:16
0

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

Dmitry Ryadnenko
  • 22,222
  • 4
  • 42
  • 56
0

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

You are looking for android.hardware.Camera.

  • Being a smartass never pays off.. Thanks :) Im going to delete the 950% bit now. haha. Got smacked right in the face. – Joey Roosing Sep 23 '11 at 10:20
  • Oh nah not smacked, i just smiled about that - because that could have been me. :D –  Sep 23 '11 at 10:23