Question

I want to make a Seek Bar that controls DTMF volume(e.g 0 to 100). I have searched a lot but could not find any thing. I am doing this but its not working..

int seekbarValue=seekBar.getProgress();
AudioManager audioManager=(AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_DTMF, seekbarValue, 0); 

Please any one tell me a solution to control DTMF volume.

Was it helpful?

Solution

None of the (AudioManager.STREAM_*) volumes go to 100 (int).

A valid stream volume for setStreamVolume(...) is between 0 and getStreamMaxVolume(int streamType).

Each stream can have a different max volume int, like 8, 10, or 16 from what I remember. Might even be different on different devices.

I hope that is enough to point you and future visitors in the right direction.

OTHER TIPS

I wanted to add a little more information to the answer of @Anonsage.

As @Anonsage mentioned, each stream has a different max volume. As per Kitkat 4.4.2 implementation, these are the max values.

  1. STREAM.DTMF: 15
  2. STREAM.MUSIC: 15
  3. STREAM.VOICECALL: 5
  4. STREAM.RINGTONE: 7

If you actually get into the lower levels and look into the AudioService.java of AOSP code, there is a rescaling operation that helps to show similar UI and update the actual values of the stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top