Question

I have written a simple application in which the user can:

  • press a button to open the camera application
  • take pictures with the camera application

Is there any way to disable the shutter sound of the camera from my code? I currently hold an Orange Nivo phone with Android 4.1.2 version on it.

A secion of my code is:

          public void onClick(View v) {
                try {
                    f = createImageFile();
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
                    startActivityForResult(cameraIntent, CAMERA_REQUEST);   
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }



            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  

            Bitmap photo = BitmapFactory.decodeFile(f.getAbsolutePath());
            Bitmap newphoto = Bitmap.createScaledBitmap(photo, 200, 200, false);     
            imageView.setImageBitmap(newphoto);

I would appreciate any suggestions on how to achieve this effect. I know that there are applications on Android store that take pictures without the shutter sound, so i suppose there must be a way to do this without rooting the phone.

Was it helpful?

Solution

The simple answer is: you can not!

The reason is that it is against the law to take a picture without the shutter making sound, this is for privacy concerns. Moreover, as you will notice, you can't take a picture even when your camera preview is not set properly, still for privacy reasons. At this point you have four options:

  • Find a way to hack the API

  • Root the phone and disable the shutter sound

  • Write your own native code for the camera...but this may be highly dependant on the device you're using it

  • Use the siplest way that is also the way used by most (if not all) the silent camera

applications in the market. Simply intercept the preview frame via the onPreviewFrame callback from your onClickListener and then save it as an image. The major drawback here is that the maximum preview resolution is far less than the maximum picture resolution so the photo you will take this way will have a fairly low resolution. Indeed if you read the comments on the silent camera apps on the market you will see a lot of people complaining about the resolution of the images not being so high. This is the reason why: they use the trick I exaplained you above.

To conclude, there is no easy way to achieve what you want!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top