Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize a new Camera.Size in Android

Tags:

android

For example:

int width = 720;
int height = 1280;

I want to create a Camera.Size.

Camera.Size size = new Camera.Size(width,height);

But it has some error.

No enclosing instance of type Camera is accessible. Must qualify the allocation with an enclosing instance of type Camera (e.g. x.new A() where x is an instance of Camera).
like image 748
jjLin Avatar asked Sep 30 '12 11:09

jjLin


2 Answers

Actually, a slightly different syntax is required:

Camera camera = Camera.open();
Camera.Size size = camera.new Size(width, height);
like image 118
Blake Avatar answered Oct 15 '22 13:10

Blake


I know you have posted your question a long time ago but I have some explanation about this error. As you can see here the class Size is declared as public (but non static) into the class Camera. You can find some information about this architecture here.

So to create a new Camera.Size object, you have to start by creating a Camera object.

Camera camera = Camera.open();

Then you can create your Camera.Size object:

Camera.Size size = camera.new Camera.Size(width, height);

I'm not sure you really want to use this way to do this, but this is the explanation about your error.

like image 22
grattmandu03 Avatar answered Oct 15 '22 13:10

grattmandu03