Android - Toggle Notification volume programmatically
A Checkbox found in the Ringer Volume settings that allows you to set a separate Notification volume and incoming call volume
Is the开发者_开发问答re a way to Check/Uncheck the Check box for Notification volume programmatically.
There is a hidden but editable preference in the Settings.System
class that determines whether the notification volume is tied to the ringer volume.
It's called NOTIFICATIONS_USE_RING_VOLUME
and is marked in the source code as hidden, with the well-commented reason that it will be removed from the platform at some point in the future.
The setting has an integer value of 0
if ringer and notification volumes are independent; 1
otherwise.
I don't recall seeing an API to do this, but you could try altering the notification (or ringer) volume programmatically to see whether that lets it "break free" of the ringer volume.
See AudioManager.adjustStreamVolume(STREAM_NOTIFICATION, ADJUST_RAISE, 0)
.
精彩评论