QAIS
QAIS

Reputation: 149

Enable shutter sound on take picture

How can I enable the shutter sound when the picture is taken? I have tried this but it is not working ! I am testing it on Galaxy y(target 2.3.6) Any hints or ideas ? Thanks in advance.

public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    mCamera.takePicture(shutterCallback, null, mPicture);
    return super.onTouchEvent(event);
}
private final ShutterCallback shutterCallback = new ShutterCallback() {
    public void onShutter() {
        AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mgr.playSoundEffect(AudioManager.FLAG_PLAY_SOUND);
    }
};

Upvotes: 2

Views: 2294

Answers (1)

Yvgen
Yvgen

Reputation: 2212

You should set not null callback

        camera.takePicture(
                new Camera.ShutterCallback() { @Override public void onShutter() { } },
                new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { } },
                jpegCallback);

Upvotes: 7

Related Questions