尝试这个,
if (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
camera.enableShutterSound(false);
}
else{
AudioManager audio= (AudioManager)this.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
currentVolume=audio.getStreamVolume(AudioManager.STREAM_SYSTEM);
audio.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
MediaPlayer media= MediaPlayer.create(SecondCamera.this,R.raw.camera_click);
media.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
isVolumeChanged=true;
}
执行上述操作,onShutter()
然后调用media.start()
onShutter()
然后onPictureTaken()
执行以下操作。
public void onPictureTaken(byte[] data, Camera camera) {
if (isVolumeChanged){
audio.setStreamVolume(AudioManager.STREAM_SYSTEM,currentVolume,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
}
}
希望这可以帮助!!!!!