拍摄照片时启用快门声音

时间:2013-10-09 19:03:46

标签: android android-camera

拍摄照片时如何启用快门声?我试过这个,但它不起作用!我在Galaxy y上测试它(目标2.3.6) 任何提示或想法? 提前谢谢。

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);
    }
};

1 个答案:

答案 0 :(得分:7)

您应该设置非空回调

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