21

Is there any way to mute the camera shutter sound in Android (not rooted phone)?

I use this code to mute my audio sound when taking picture:

  AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    int streamType = AudioManager.STREAM_SYSTEM;
    mgr.setStreamSolo(streamType, true);
    mgr.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    mgr.setStreamMute(streamType, true);

I mute the sound and silent the phone.

mCamera.takePicture(null, null, photoCallback); 

then take the picture

It's working on HTC HERO, HTC Desire, Motorola ME860, MotoA953. But when I tested it on Samsung Tab p1000 and Sony Experia R800i, it's not working. Is there any other work around?

user430926
  • 4,017
  • 13
  • 53
  • 77
  • see this http://wiki.dandascalescu.com/howtos/android#How_do_I_disable_the_camera_shutter_sound.3F – MAC Apr 30 '12 at 11:47
  • 3
    Follow these two links: http://stackoverflow.com/questions/8906909/how-do-i-change-default-shutter-sound-in-android http://stackoverflow.com/questions/9106939/android-camera-takepicture-possible-to-disable-shutter-sound-and-preview-surfa – Krishnakant Dalal Apr 30 '12 at 11:48
  • 1
    Did you try setting the shutter callback to null? How are you taking the picture? – Tyler May 15 '12 at 03:54
  • mCamera.takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg) mCamera.takePicture(null, null, photoCallback); I did set the shutter callback null – user430926 May 15 '12 at 08:58

5 Answers5

8

try this code:

AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if(TextUtils.equals(muteMode, "mute")){
    manager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0 , AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
}else{
    manager.setStreamVolume(AudioManager.STREAM_SYSTEM, manager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM) , AudioManager.FLAG_ALLOW_RINGER_MODES);
}
//here continue to take picture...

do not use AudioManager.setStreamMute() method since there is a known issue on android below version 2.3..

Kimia Zhu
  • 209
  • 2
  • 2
  • it works with 2.3.3, but you need to make the mute call before you call takePicture() and the unmute in the ShutterCallback.onShutter() – Miron Ophir Aug 01 '13 at 12:04
7

Since API level 17 (4.2) there is a proper, reliable way to do this, if the phone manufacturer supports it.

First, detect whether you can disable the shutter sound programatically, then disable it

Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(id, info);
if (info.canDisableShutterSound) {
    mCamera.enableShutterSound(false)
}

You'll need to set id to the appropriate camera id in the call to Camera.getCameraInfo, or disable them all in a loop from 0 to Camera.getNumberOfCameras()- 1.

The developer documentation recommends that you play another sound in place of the shutter sound, but you're not obliged to.

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
4

The method you've posted already is actually the best one I can find/think of. The reason it doesn't work is because it's not supposed to. In fact, in many places (most of Europe, Japan, parts of US, etc.) it's illegal to disable the shutter sound. This is so that you can't take pictures in places you're not supposed to, and so you don't take pictures of people without their permission, and so on. It's just a shot in the dark that the manufacturer has purposely tried to make sure you can't do it no matter what (though technically there's always a way), but when you think about it, logically there's no reason your code shouldn't work right? It's simple, basic, makes sense. Anyways, there are many silent camera apps out there and Camera+ ICS is actually built on the default ICS camera but has a Silent Shutter option so it must be possible.

  • I found [a reference about shutter sounds being required](https://www.privacyinternational.org/reports/south-korea/ii-surveillance-policy) in South Korea, but nothing about the US. Can you point me to a document explaining the legal status of this in the US? AFAICT [this proposed bill](http://www.govtrack.us/congress/bills/111/hr414) never passed. – cberzan Oct 26 '12 at 01:50
3

there are a phones out there which play the shutter sound on their own. In this case, it seems to not be possible to disable the shutter sound.

Rookie
  • 8,660
  • 17
  • 58
  • 91
2

One crazy way i can think is to get the permission to mute the phone.

Liam
  • 2,837
  • 23
  • 36