1

I've gotten the front-facing camera to work on a Samsung Galaxy S, but the following technique doesn't work on an LG Optimus 2X Speed:

Camera mCamera = Camera.open();
Camera.Parameters parameters = mCamera.getParameters();
parameters.set("camera-id", 2);
mCamera.setParameters(parameters);

The above code still only displays video from the back-facing camera. The Camera app supports switching cameras, and it even comes bundled with a "Mirror" app.

Community
  • 1
  • 1
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187

1 Answers1

2

I revealed all the parameters using

Camera.Parameters parameters = mCamera.getParameters();
Log.d("camera", parameters.flatten());

Which revealed a field called camera-sensor. Surely enough, I got it working by specifying

parameters.set("camera-sensor", 1);
mCamera.setParameters(parameters);
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • I got briefly excited when I read this - maybe this is a way to switch cameras that's faster than release/open! But as your experience suggests, the string parameters are device-dependent. On a Galaxy Nexus, for example, `flatten()` shows that the only `camera-` parameter is `camera-name`. – Jon Shemitz Jul 11 '12 at 22:44
  • I believe that despite the parameter you still need release and open the camera to switch. – Paul Lammertsma Jul 12 '12 at 09:28