I went the other way. This is not quite the answer to my question, but appropriate. When I play the notification in STREAM_MUSIC, everything is fine. Thus, the notification is reproduced exactly with the volume that I pass as a parameter to the function
private void beep(int volume)
{
AudioManager manager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
manager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
Uri notification = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
MediaPlayer player = MediaPlayer.create(getApplicationContext(), notification);
player.start();
}
source
share