0

i have an issue regardin my test App, in wich i try to create a View like in a Samsung Galaxy -> Settings -> Sound-> Volume, but instead of all Volume Controler, and the two buttons OK
Cancel, i want just Ringer Volume and a Save button.I am new in android and really don't know why my code below behave bad.

public class SaveActivity extends Activity {

    private AudioManager aManager;
    private SeekBar seekVolume;
    private Button save;
    public int main_progress;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        aManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        Button save = (Button) findViewById(R.id.save);
        seekVolume = (SeekBar) findViewById(R.id.seekVolume);
}

    public void saveOnClickListener(View view){

            int keyCode = 0;
            KeyEvent keyEvent;
            seekVolume.setMax(aManager.getStreamMaxVolume(AudioManager.STREAM_RING));
            seekVolume.setKeyProgressIncrement(1);
            seekVolume.setProgress(aManager.getStreamVolume(AudioManager.STREAM_RING));


            seekVolume.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

                public void onStopTrackingTouch(SeekBar ringvolume) {


                }

                public void onStartTrackingTouch(SeekBar ringvolume) {


                }

                public void onProgressChanged(SeekBar ringvolume, int progress ,
                        boolean fromUser) {
                     main_progress=progress;
                     aManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, progress, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
                }

            });


             aManager.setStreamVolume(AudioManager.STREAM_RING, main_progress, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
            if(keyCode==KeyEvent.KEYCODE_VOLUME_DOWN || keyCode==KeyEvent.KEYCODE_VOLUME_UP){


            }else if (keyCode==KeyEvent.KEYCODE_VOLUME_DOWN || keyCode==KeyEvent.KEYCODE_VOLUME_UP){



}
    }


}
  • can you post a picture of what you are wanting? "Samsung Galaxy" is not a specific device, this is a generic name for a line of samsung devices. some of which may have differently skinned settings menus – FoamyGuy Jun 13 '12 at 15:36
  • @Tim here is the picture. Thx mate [link] (http://picz.ro/index.php?id=51451550efe7d33e4dd123e046d0068d) – ionutz staniu Jun 13 '12 at 15:47
  • @Tim, please see my comment to your answer. Thanks! – ionutz staniu Jun 13 '12 at 17:09

1 Answers1

0

Looks to me like that is a Custom AlertDialog that contains a LinearLayout filled with 4 SeekBar

When you say your code is "behaving bad" what exactly do you mean? Do you get an error or just unexpected behavior, please elaborate some more on what it is currently doing.

Community
  • 1
  • 1
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • ,When i am saying that is behaving bad, i mean the app has unexpected behaviour: When i move the seekBar (Upper or lower), and then press the "Save" button, the ringer volume FLAG_UI pop-up, but with minimum value, not changing at all. For short: i want first to move on seekBar, and than save the changes by pressing "Save" Button – ionutz staniu Jun 13 '12 at 17:07