在我的应用程序中,我需要播放响亮的声音作为紧急警报。我正在尝试这个,但如果可能的话,我想产生更大的声音(我能得到的最大声)。
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_DTMF, audioManager.getStreamMaxVolume(AudioManager.STREAM_DTMF), AudioManager.FLAG_PLAY_SOUND);
ToneGenerator tone = new ToneGenerator(AudioManager.STREAM_DTMF, 100); // 100 is max volume
tone.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500); // 500ms
Run Code Online (Sandbox Code Playgroud)
你知道如何发出最响亮的声音吗?
| 归档时间: |
|
| 查看次数: |
4781 次 |
| 最近记录: |