Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Front Facing Camera on Samsung Galaxy S

I've tried several answer I've found across the web, such as:

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

or

mMediaRecorder.setVideoSource(2);

But it doesn't work. I've also set permissions on the manifest file:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />

Am i missing out on something? I've searched StackOverflow and I know this has been asked before but there seem to be no confirmed solution on this, any kind of help would be appreciated.

Note: I'm using Galaxy S on the 2.1 platform

like image 330
Muhammad Abdullah Avatar asked Nov 22 '10 00:11

Muhammad Abdullah


People also ask

How do you turn on front facing camera on Samsung?

Open the Camera app and make sure the front facing camera is activated. To do this, swipe up or down on the screen or tap the Flip Camera icon. To use a different Camera mode, swipe left or right.


1 Answers

Anyway after a few trials and error, I figured it out how to do it:

Camera.Parameters parameters = mCamera.getParameters();
parameters.set("camera-id", 2);
parameters.setPreviewSize(640, 480); // or (800,480) this is supported front camera preview size @ Samsung Galaxy S
mCamera.setParameters(parameters);

Or, if you need to use it with MediaRecorder:

MediaRecorder mMediaRecorder = new MediaRecorder();
Camera mCamera = Camere.open();
Camera.Parameters parameters = mCamera.getParameters();
parameters.set("camera-id", 2);
parameters.setPreviewSize(640, 480); // or (800,480)
mCamera.setParameters(parameters);
mCamera.unlock(); // unlock, to give other process to access it otherwise it can't be used later
mMediaRecorder.setCamera(mCamera);
// continue with mMediaRecorder standard routines here

If you need to have a smaller preview size, you could set/scale down your SurfaceView size instead.

like image 139
Muhammad Abdullah Avatar answered Oct 21 '22 15:10

Muhammad Abdullah