I am trying to write a custom camera application in android. For that I need to open the camera application.
for that i am tring following code..
Camera camera = Camera.open();
but is showing error like
method open undefined for type Camera
i did as suggested here http://developer.android.com/reference/android/hardware/Camera.html#open(int)
any suggestion..
Thanks, Ravindra Gupta
You most likely imported the wrong camera class at the top of your source file, which is android.graphics.Camera
.
You need android.hardware.Camera
instead.
Thanks
I think you have not added the camera permission. See below - you need to add this in your manifest;
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Check your imports. I had a similar problem and the Camera object Eclipse chose for me was: import android.graphics.Camera;
instead it should be: import android.hardware.Camera;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With