Open front camera using MediaStore.ACTION_IMAGE_CAPTURE

2.9k Views Asked by At

Hello friends I want to use front camera in my app using

MediaStore.ACTION_IMAGE_CAPTURE

This is the method which I'm using

 public void CaptureImage(int request){
    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
    cameraIntent.putExtra("android.intent.extras.LENS_FACING_FRONT", 1);
    cameraIntent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true);
    startActivityForResult(cameraIntent, request);
}

But it open back camera , what I want is front camera of device.

1

There are 1 best solutions below

0
Android Geek On

I have use this code to open front camera

use this line in camera intent to open front camera

intent.putExtra("android.intent.extras.CAMERA_FACING", 1);

Code

    /*for getting image using camera*/
private void cameraIntent() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
    startActivityForResult(intent, GlobalString.REQUEST_CAMERA);
}