0

Doese anyone know of a tutorial on how to make a Volume Controller like this one (with a Save button at the bottom). This is my problem, how to make that "Save" button. I can create all the volume SeekBars, but unfortunately when I make changes on SseekBar it automatically changes the volume from the phone settings (ringer, notification, media, in call).

Thanks in advance.

slybloty
  • 6,346
  • 6
  • 49
  • 70
  • So what volume do you want to change and save? If it already changes the volumes, why do you want to save it? – slybloty Jun 11 '12 at 19:05
  • @slybloty I want to have a Panel with all Volumes from Phone (Just like in Sound Settings from an ANdroid Phone) with "OK" and "Cancel" Button. I don't want acctualy, when i move the seekBar to change instantly the volume. First move the seekBar, then press "Save" to save the changes – ionutz staniu Jun 11 '12 at 19:36

1 Answers1

1

First off, use the SeekBar and retrieve the value it sets to. Don't set the volumes while the SeekBar is adjusted. And then, when the button Save is pushed, send those values to the AudioManager.

Use this link for more detailed explanation: Android Development: Change Media volume? as well as this one: SeekBar1.java

Here's a quick example of how it might look like:

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);

ImageButton save = (ImageButton) findViewById(R.id.save);

save.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, valueFromSeekBar, flagIfNeeded);
    }
}); //End setOnClickListener()
Community
  • 1
  • 1
slybloty
  • 6,346
  • 6
  • 49
  • 70
  • Thanks for the search mate, but how can i send those valuse to AudioManager when **Save** is pushe? i mean in `save.setOnCLickListener(new View.OnClickListener){ // code}` ? – ionutz staniu Jun 11 '12 at 20:00
  • Yes, that's the idea. I've improved my answer to reflect it. – slybloty Jun 11 '12 at 20:28
  • Thanks a lot Mate. Now i have an ideea how could work. At first runtime, my apps get crash, but i'll figure it out . – ionutz staniu Jun 11 '12 at 21:09