简体   繁体   English

在Android(使用Java)中,如何设置铃声音量(指定的数量)?

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

So in my application, I have a seekbar that allows the user to set the ringer volume (0 - 100). 所以在我的应用程序中,我有一个搜索栏,允许用户设置铃声音量(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. 我查看了AudioManager类,但它告诉我要么将ringermode设置为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? 这在Android中可行吗? If so, how? 如果是这样,怎么样? Can you give me an example of how I can do this? 你能告诉我一个如何做到这一点的例子吗?

Thank you. 谢谢。

Look up the AudioManager ( documentation here ). 查找AudioManager( 此处的文档 )。 It should have everything you need, including setVibrateSetting , setRingerMode , setStreamVolume . 它应该包含您需要的一切,包括setVibrateSettingsetRingerModesetStreamVolume All those settings are separate from each other. 所有这些设置彼此分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM