0

In my app I want to open native front camera as default as it my requirement. I tried putExtras and send it as intent but it is not working as below :

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING",android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
            startActivityForResult(intent, RESULT_LOAD_CAMERA);

Can you please help me out as it is my app requirement?

Thanks

Bansi Doshi
  • 229
  • 1
  • 3
  • 12

1 Answers1

0

What you are trying is a hack. It is using a testing code of the Camera app. And i guess it was disabled from Android L. Go for fetching instance of front facing camera and loading in your own view.

Camera c = null;  // object that use
Camera.CameraInfo info = new Camera.CameraInfo();
int count = Camera.getNumberOfCameras();

for (int i = 0; i<cameraCount; i++) {
     Camera.getCameraInfo(i, info);
     if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
     try {
        c = Camera.open(i);
     } catch (RuntimeException e) {
       // Handle
     }
   }
}

This code will fetch front facing camera's object and you can use it for your purpose.

Neji
  • 6,591
  • 5
  • 43
  • 66