How to set notification sound volume programatically?

Posted by Vitalii Korsakov on Stack Overflow See other posts from Stack Overflow or by Vitalii Korsakov
Published on 2012-07-02T21:12:43Z Indexed on 2012/07/02 21:15 UTC
Read the original article Hit count: 358

I have this method in my main activity

private void beep()
{
    AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    manager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0,
            AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
    Uri notification = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(getApplicationContext(),
            notification);
    r.play();
}

As I understand, notification sound volume should be regulated by STREAM_NOTIFICATION. But notification always plays with the same volume despite that volume number in setStreamVolume method. Why is that?

© Stack Overflow or respective owner

Related posts about android

Related posts about notifications