In Android (using Java), how can I set the ring volume (to a specified number)?

ぐ巨炮叔叔 提交于 2020-01-13 10:50:17

问题


So in my application, I have a seekbar that allows the user to set the ringer volume (0 - 100). I can't seem to find a way to set the ringer volume to a specified number. I looked through the AudioManager class but it tells me to either set ringermode to normal/silent/vibrate. That is NOT what I want. I want the volume to be a specific number. Here's an example of what I'm looking for:

private void setRinger (int volume) // volume = 0 - 100
{
    setRingVolume (volume); // Whenever a person gets a call/sms/warning/anything etc., it should be this volume.
}

Is this possible in Android? If so, how? Can you give me an example of how I can do this?

Thank you.


回答1:


Look up the AudioManager (documentation here). It should have everything you need, including setVibrateSetting, setRingerMode, setStreamVolume. All those settings are separate from each other.



来源:https://stackoverflow.com/questions/4295333/in-android-using-java-how-can-i-set-the-ring-volume-to-a-specified-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!