我的应用程序发出警报。在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(); }我想念什么?
添加回答
举报
0/150
提交
取消