0

I am brand new at android development. Sorry if I sound obtuse.

I want to write a pretty simple program that turns the flash LED on or off. So far what I have amounts to an import statement that looks like this.

import android.hardware.Camera.Parameters;

And I'm trying to create a parameters object like this.

Parameters flash = new Parameters(this);

Currently the error reads "Camera cannot be resolved to a type". What is the orrect way to create this object. I suspect I need to pass more/different data to the constructor. Again, new at this so please go easy.

yawningdog
  • 11
  • 3
  • http://stackoverflow.com/questions/6068803/how-turn-on-only-camera-flash-light-programmatically-in-android – sled Jul 26 '11 at 20:54
  • The Camera object does not have a public constructor - usually you get a Camera-Object by doing "Camera c = Camera.open();". Although in this case you seem to miss some import. There is a small step-by-step guide in the Camera class overview, check that out: http://developer.android.com/reference/android/hardware/Camera.html. –  Jul 26 '11 at 20:55

2 Answers2

2

You've imported Parameters, not Camera. I'm not familiar with Android namespaces, but you probably need to import android.hardware.Camera; or something.

PersonThing
  • 388
  • 2
  • 10
1

Ok after you edited that:

You can't create a parameter object from scratch. The parameter object has also no public constructor.

The usual way to do this is create a camera object, use camera.getParameters() to get the current parameters. Then you can edit them and use camera.setParameters() to write these params back (At this point they will take effect). My link from above is still useful to read here.

In the end it should like this pattern:

Camera cam = Camera.open();
Parameters p = cam.getParameters();
p.set...();
cam.setParameters(p);

Since you have problems with an import above: If you are using eclipse, there is one very handy shortcut. Press Ctrl+Shift+O ("Organize Imports"). This will automatically search for required imports and add them to the current file. Unneccessary ones also get removed. This way you won't have to search for the correct imports. If an import is not clear, eclipse will usually ask what to do.