使用 Xamarin 在 Android 手机上以编程方式设置铃声音量



以下代码运行良好

AudioManager am = (AudioManager)this.GetSystemService(Context.AudioService);
am.RingerMode = RingerMode.Vibrate;

因此,运行它后,环形音量变为 0,但我想将其设置为自定义值,例如"57"。

为此,我使用了以下代码:

AudioManager am = (AudioManager)this.GetSystemService(Context.AudioService);
am.SetStreamVolume(Stream.Ring, 57, 0);

在此代码运行后,我的环形卷没有任何变化,我预计它会更改为"57"值。

我在Android 7.0版本上使用最新的Xamarin库。我只需要为安卓实现这一点。

此自定义环体积是否设置了限制?这am.SetStreamVolume(Stream.Ring, 57, 0);实际应该做什么(如果它没有改变手机的铃声音量)。

您可以先使用 GetStreamMaxVolume 获取特定流的最大值,然后设置一个小于最大值的适当数字。

最新更新