Steps for adjusting the voice of a mobile phone in Android:
A. Obtain the Sound Manager through the System Service:
AudioManager audioManager = (AudioManager) getSystemService (Service. AUDIO_SERVICE );
B. Call appropriate methods as needed: (common methods)
AudioManager. adjustStreamVolume (int streamType, int direction, int flags );
StreamType: Specifies the sound type, which can be STREAM_VOICE_CALL, STREAM_SYSTEM, STREAM_RING, and STREAM_MUSIC) or STREAM_ALARM (warning sound ).
Direction: adjust the volume direction. It can be ADJUST_LOWER (turn down the volume), ADJUST_RAISE (turn up the volume), or ADJUST_SAME (keep the previous volume ).
Flags: Optional flag (to display the volume adjustment UI, use the following flag: AudioManager. FLAG_SHOW_UI ).
AudioManager. setStreamMute (int streamType, boolean state); Sets whether the specified streamType is set to mute. If the state is true, it is set to mute; otherwise, it is not set to mute.
AudioManager. setRingerMode (int ringerMode );
Set the ringtone mode to RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE ).
AudioManager. setMode (int mode );
Set the sound mode, which can be set to MODE_NORMAL (normal mode, that is, when there is no Bell tone or phone call), MODE_RINGTONE (ring tone mode), MODE_IN_CALL (call mode) or MODE_IN_COMMUNICATION (call mode ).
Note: There is no permission requirement for sound adjustment.
From tianshijianbing1989