Get the device volume

Started by
1 comment, last by 6677 11 years, 7 months ago
I will explain my situation briefly:

Let's say I'm on my android phone and I set the volume to 0 (silent).
Then I start my application. Inside my app, I start playing music (using MediaPlayer).
I don't want the music to start playing - but it does, even though the phone is silenced. I'm not saying that's wrong.

So what I want to do is to "get" the volume of the device (it would have to be 0 or 0.0 in this case) and set it using: audioManager.setStreamVolume().

How can I get that information?
Advertisement
I'd try adjustSuggestedStreamVolume instead.

That will raise and lower the volume by one increment, and it will operate correctly if the device has weird audio streams.
Just an FYI, android maintains 3 seperate volume levels. Ringer volume (which is what the silent mode refers to), Media volume (which I think is the only one apps can play with directly) and In call volume.

This topic is closed to new replies.

Advertisement