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.

asked Jul 26, 2011 at 20:50
2
  • stackoverflow.com/questions/6068803/… Commented Jul 26, 2011 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: developer.android.com/reference/android/hardware/Camera.html. Commented Jul 26, 2011 at 20:55

2 Answers 2

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.

answered Jul 26, 2011 at 20:52
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, I mistyped the code. I'm creating a Parameters object, not a camera object.
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.

answered Jul 26, 2011 at 21:04

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.