我的应用会发出警报。在 Android 声音设置中,此声音由“响铃音量”滑块而不是“闹钟音量”滑块控制。如何更改由“警报音量”控制的声音?
public void doAlarm(){
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
r = RingtoneManager.getRingtone(getApplicationContext(), notification);
if (!r.isPlaying())
r.play();
}
我曾尝试使用 setAudioAttributes,但结果是“媒体音量”滑块控制了音量:
public void doAlarm(){
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), notification);
mp.setAudioAttributes(new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM).build());
mp.setLooping(true);
mp.start();
}
我错过了什么?