I'm trying to add click image of user from Android mobile app in Android studio, and want open front camera always instead of back camera. But it only works on some devices and I want it to work with every device. Currently I'm using an OnePlus, which doesn't open the front camera
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT);
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
I've tried this
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT); startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
The constant
Camera.CameraInfo.CAMERA_FACING_FRONTwas deprecated in Android API 23. You should use the constantCameraCharacteristics.LENS_FACING_FRONTinstead.Try adding the following extra to the intent:
You can also use CameraX library to open the front camera: