0

Possible Duplicate:
Using SeekBar to Control Volume in android?

How can i set the volume using seekbar in my android application?? I want to accurate the ringer volume from my application rather to set it from phone. Any thoughts ??

Community
  • 1
  • 1
Jasmeet Kaur Chauhan
  • 1,209
  • 1
  • 11
  • 16
  • 1
    [Possible Duplicate](http://stackoverflow.com/q/10134338/940096) – Praveenkumar Jun 20 '12 at 09:52
  • You can simply try the user [Chirag Raval's answer](http://stackoverflow.com/a/10134544/940096) from this [existing question](http://stackoverflow.com/q/10134338/940096) Controlling the volume working based on [AudioManager](http://developer.android.com/reference/android/media/AudioManager.html) – Praveenkumar Jun 20 '12 at 09:56

1 Answers1

1

Here you go

AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    volumeSeekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING));
    volumeSeekbar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_RING));


    volumeSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar arg0) {}

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {}

        @Override
        public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {
            audioManager.setStreamVolume(AudioManager.STREAM_RING, progress, 0);
        }
    });
Vipul
  • 31,716
  • 7
  • 69
  • 86
  • http://stackoverflow.com/questions/10134338/using-seekbar-to-control-volume-in-android this answer help me it is correct so it may be help you.. – Jelly Bean Feb 26 '14 at 11:17