Reputation: 21
I am trying to change volume of notifications, but not ringer. However, when I use this function notification and ringer volume are changed.
Example code:
AudioManager mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
int volNot = mAudioManager.getStreamVolume(STREAM_NOTIFICATION);
int volRing = mAudioManager.getStreamVolume(STREAM_RING);
Log.d(volNot + "," + volRing, "not, ringer");
mAudioManager.setStreamVolume(STREAM_NOTIFICATION, 1, 0);
volNot = mAudioManager.getStreamVolume(STREAM_NOTIFICATION);
volRing = mAudioManager.getStreamVolume(STREAM_RING);
Log.d(volNot + "," + volRing, "not, ringer");
For result setStreamVolume(STREAM_NOTIFICATION, 1, 0)
changes value of notifications(STREAM_NOTIFICATION)
to 1, but it also changes value of ringer(STREAM_RING)
to 1.
Upvotes: 2
Views: 11234
Reputation: 1703
Since ICS (Android 4.0), Ringer and Notification shares volume stream in official Android ROMS. Before this, user could choose to split the streams.
Upvotes: 0
Reputation: 3280
This is because the phone has a setting in sounds---> volume in which there is a tick box which is checked, uncheck it and try your code again, this setting says that the ringer volume will be your notification volume and visa-verse.
Upvotes: 4