1

i am creating an camera app which will set the flash to auto mode.i am using intent to launch the camera app.I tried the folllowing code but flash remains off

      Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
                Camera cam = Camera.open();
                Camera.Parameters p = cam.getParameters();
                p.setFlashMode(Parameters.FLASH_MODE_AUTO);
                cam.setParameters(p);
                cam.startPreview();
                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

                // start the image capture Intent
                startActivityForResult(cameraIntent,CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
shivadeep
  • 68
  • 1
  • 11
  • Try these answers on SO- [this](http://stackoverflow.com/a/23337134/3921977) and [this](http://stackoverflow.com/a/6069503/3921977). – Aishwarya Tiwari Apr 10 '17 at 06:35

2 Answers2

0

Add these to manifest file:

android.hardware.camera.autofocus

android.hardware.camera.flash
Saurav Prakash
  • 588
  • 1
  • 5
  • 26
0

try with

p.setFlashMode(Parameters.FLASH_MODE_ON);
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147