AudioManager getVolume custom method

My getVolume() method is always returning me 1.0. I have muted my phone, changed the volume but I am getting 1f anytime when I call my method. Am I missing something?

btnPlay.setOnClickListener(new OnClickListener(){
   public void onClick(View v){
      float volume = getVolume();
      Log.i("inf", "Volume: " + volume);
      soundPlayID =, volume, volume, 1, 0, 1f);

private float getVolume(){
    AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    float maxVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    float volume = actualVolume / maxVolume;

    return volume;


Volume: 1.0

Volume: 1.0

Volume: 1.0

Volume: 1.0


The maxVolume here appears to be the SAME as the volume. The calls are identical, and so you will always get 1.0 as a result.

You need to call:


and then you should see more interesting results.