I know i can set a `boolean flag while opening front Camera`. And if flag is true it means front camera is on. 

But is there a way using Android API to know which Camera is Open right now? Front or Back.

```
public int getFrontCameraId() {
    CameraInfo ci = new CameraInfo();
    for (int i = 0 ; i < Camera.getNumberOfCameras(); i++) {
        Camera.getCameraInfo(i, ci);
        if (ci.facing == CameraInfo.CAMERA_FACING_FRONT) return i;
    }
    return -1; // No front-facing camera found
}

```

Camera Preview is inverting(upside donw) when i open Front Camera. So i have to add a check which Camera is open `if FrontCamera is opened then matrix = 270. otherwise matrix =90.`

**onPreviewFrame(byte abyte0[] , Camera camera)**

```
 int[] rgbData = YuvUtils.decodeGreyscale(abyte0, mWidth,mHeight);

    editedBitmap.setPixels(rgbData, 0, widthPreview, 0, 0, widthPreview, heightPreview);

    finalBitmap = Bitmap.createBitmap(editedBitmap, 0, 0, widthPreview, heightPreview, matrix, true);

```