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);
m开发者_JAVA百科Camera.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.
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);
精彩评论