I am turning the ringer on, hence the use of 2, not 0. I use 0 when I am turning it off. It only beeps when I turn it on, but it is that beep that is causing my problem.
I have all the permissions set properly, the code does work. Just not quietly.
None of these was successful. Tried with the various Volume settings channels (VOLUME_NOTIFICATION, VOLUME_ALARM, VOLUME_SYSTEM, VOLUME_RING).
Seems others who have had a problem with the beep when the volume controls are adjusted, and some with rooted phones have solved it by disabling the sound file that plays. Not a solution for me, my phone is not rooted and I would not expect others to root theirs to use my app.
Not sure where to go from here.