停止相机咔嚓声编程的机器人机器人、相机

2023-09-05 06:54:46 作者:典型小二货

我使用Android的默认摄像机从内我的应用程序单击图像。我想停止它的点击图像的点击声。有没有办法制止这种咔嚓声programtically?

I am using android's default camera to click images from within my app. I want to stop the click sound that it does on clicking an image. Is there a way to stop that click sound programtically?

感谢。

推荐答案

要关闭声音使用该code:

To disable sound use this code:

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

要启用声音使用该code:

To enable sound use this code:

mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
streamType = AudioManager.STREAM_SYSTEM;
mgr.setStreamSolo(streamType, false);
mgr.setRingerMode(AudioManager.RINGER_MODE_SILENT);
mgr.setStreamMute(streamType, false);