No enclosing instance of type Camera is accessible

Put your problem here if it does not fit any of the other categories.

No enclosing instance of type Camera is accessible

Postby yccheok » Thu Mar 01, 2012 3:26 am

I have the following code

Code: Select all
android.hardware.Camera.Size size = new android.hardware.Camera.Size(300, 300);


I get the following compilation error

No enclosing instance of type Camera is accessible


However, I check the documentation, it is a public constructor

http://developer.android.com/reference/android/hardware/Camera.Size.html#Camera.Size%28int,%20int%29

Anything I had missed out?
yccheok
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed May 25, 2011 1:31 pm

Top

Re: No enclosing instance of type Camera is accessible

Postby Phyll » Thu Mar 01, 2012 11:24 pm

Hi yccheok,

I think you need something like this first:

mCamera = Camera.open();

That's how my app that uses the camera works. Everything is done through mCamera then. I don't change the size either. If I want a smaller size, to send it somewhere for instance, I make it smaller with Bitmap.compress() at the time.

I tried what you did and it did the exact same thing to me. Wanted size to be of type Camera but if it was made to be that type, it wanted it to be Size. Didn't make sense.

EDIT

Boy do I feel stupid. I finally figured out that is an inner class. Here's what Java says about that:

To instantiate an inner class, you must first instantiate the outer class. Then, create the inner object within the outer object with this syntax:

OuterClass.InnerClass innerObject = outerObject.new InnerClass();

Here's where you can get the whole story if you're interested:

http://docs.oracle.com/javase/tutorial/ ... ested.html

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests