You need to set the camera's auto-exposure mode to one of the flash-using ones; generally that's either AE_MODE_ON_AUTO_FLASH or AE_MODE_ON_ALWAYS_FLASH.
You can check which modes are available on your device via AE_AVAILABLE_MODES.
Then you'll need to use the AE precapture trigger before doing the main image capture, so that a preflash can be fired for accurate flash brightness control.
- Ensure your preview request has the desired AE flash mode, have it set as the repeating request for your capture session.
- Create a new capture request builder with your preview settings.
- Set the precapture trigger to START for that builder
- Create one request with that builder, and call CameraCaptureSession.capture() with it
- Wait for the AE_STATE of PRECAPTURE to appear and disappear; during this time the camera device may light up the flash to measure how bright it needs to be.
- Once AE_STATE_PRECAPTURE ends, issue the high-resolution capture request using the STILL_CAPTURE template (which sets the capture intent control to STILL_CAPTURE, triggering the main flash firing).
The Camera2Basic sample includes all this for flash operation, as a sample to follow. It uses AE_MODE_AUTO_FLASH if supported by the device.