How to adjust the voice of mobile phones in Android (Android Learning Guide 4)

Source: Internet
Author: User

 

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.