I'm working on android marshmallow. In my application I'm trying to open android mobile front camera pro grammatically for capturing users profile pic & to display it for preview I've tried lot of examples available that're available in the internet none of the app given perfect out put every example is showing loading of back camera on button click.
Asked
Active
Viewed 1,565 times
-1

Cœur
- 37,241
- 25
- 195
- 267
-
Please provide a [mcve] demonstrating your problem. – CommonsWare Apr 28 '16 at 17:42
-
@CommonsWare this is the URL link I followed [link](http://www.vogella.com/tutorials/AndroidCamera/article.html ) – Apr 28 '16 at 18:18
1 Answers
0
You can access Front camera by
Camera.CameraInfo.CAMERA_FACING_FRONT
and here is the example method you can use to access it
private Camera openFrontFacingCameraGingerbread() {
int cameraCount = 0;
Camera cam = null;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
try {
cam = Camera.open(camIdx);
} catch (RuntimeException e) {
Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
}
}
}
return cam;
}

Atiq
- 14,435
- 6
- 54
- 69