Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

audio - How to mute camera shutter sound on android phone

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...