Saturday, June 22, 2013

[android help] How to start front facing camera in android Using Camera Intent?


How to start front facing camera in android Using Camera Intent?



I am developing an app in which I want to open front camera on button click (if front camera is present on that device).


I have use this code which works for me on Asus Tablet having OS 3.2.1. But same code is not working on OS 4.2.1.


I want the code which works on all android versions. Please help me in this problem.


Following is my code-



Intent takePictureIntent = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);

takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(f));
Log.v("", "Camera Id-" + camId);

if (!TextUtils.isEmpty(camera)) {
if (camera.equalsIgnoreCase("Front")) {
Log.v("", "Inside if");
takePictureIntent.putExtra(
"android.intent.extras.CAMERA_FACING",
Camera.CameraInfo.CAMERA_FACING_FRONT);

} else {
Log.v("", "Inside else");
takePictureIntent.putExtra(
"android.intent.extras.CAMERA_FACING",
Camera.CameraInfo.CAMERA_FACING_BACK);

}
}
startActivityForResult(takePictureIntent, actionCode);


.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...