android mute camera shutter sound?

android, android-camera

Solution

To mute, put this code before capturing an image

 AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
 mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
 camera.takePicture(null, rawCallback, jpegCallback);

After 1 second it will unmute by putting in the below code:

 final Handler handler = new Handler();
 Timer t = new Timer();
 t.schedule(new TimerTask() {
    public void run() {
        handler.post(new Runnable() {
            public void run() {
            AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
            mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false);
                    }
                });
            }
    }, 1000); 

Problem

I am using this `camera.takePicture(null, rawCallback, jpegCallback);` but with some devices it makes a sound when the camera captures the image. Please can any one help, how can I mute camera shutter sound?

Original source