Question: I am trying to get a camera instance by camera = getCameraInstance(); , but getCameraInstance() gets red underlined and says create method getCameraInstance() . I don't know what the problem is : 

```
import android.app.Activity;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.os.Bundle;  
import android.view.Menu;
import android.view.MenuItem;

public class CameraActivty extends Activity implements PictureCallback{

private Camera camera;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    camera = getCameraInstance();

}

@Override
public void onPictureTaken(byte[] data, Camera camera) {
    // TODO Auto-generated method stub

}
}

```

I have declared camera permission in manifest also.

Answer: 
There is no method on `Activity` named `getCameraInstance()`. You either need to write that method yourself, or you need to rewrite that line to avoid referring to a non-existent method.
**I am using this to getCameraInstance in my App.**

```
private static Camera getCameraInstance()
    {
        Camera camera1;
        try
        {
            if (android.os.Build.VERSION.SDK_INT >= 9) 
            {
                return Camera.open(cameraId); 
            }
            camera1 = Camera.open();
        }
        catch (Exception exception)
        {
            return null;
        }
        return camera1;
    }

```