Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:58:30+00:00 2026-06-05T08:58:30+00:00

i am new in android development, and i’m trying to figure out how cand

  • 0

i am new in android development, and i’m trying to figure out how cand i make a button to save changes in a Activity. Brief: i have a seekBar where i can change the ringer volume, but it changes directley for System, i put a Button to Save the changes, and i don’t know how to do this. This is my code:

main.xml

 <Button
        android:id="@+id/save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_text"/>

    <SeekBar
        android:id="@+id/seekVolume"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

Activity

public class SaveActivity extends Activity {

    private AudioManager aManager;
    private SeekBar seekVolume;

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

        aManager = (AudioManager) getSystemService(AUDIO_SERVICE);
        Button save = (Button) findViewById(R.id.save);

        setOnClickListener();      
}
    private void setOnClickListener(){
        SeekBar seekVolume = (SeekBar) findViewById(R.id.seekVolume);

        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) {
aManager.setStreamVolume(AudioManager.STREAM_RING, progress, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND); 
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
        if(keyCode==KeyEvent.KEYCODE_VOLUME_DOWN || keyCode==KeyEvent.KEYCODE_VOLUME_UP){
            seekVolume.setProgress(aManager.getStreamVolume(AudioManager.STREAM_RING));
    }
        return (super.onKeyDown(keyCode, event));
    }

}

I really don’t know how to do this. Thanks Guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:58:32+00:00Added an answer on June 5, 2026 at 8:58 am

    To read your preferences (in onCreate()):

    SharedPreferences preferences = getPreferences(MODE_PRIVATE);
    seekVolume.setProgress(preferences.getInt("storedVol", 0));
    

    To save your preferences (in onDestroy()):

    SharedPreferences preferences = getPreference(MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putInt("storedVol", seekVolume.getProgress()); // value to store
    editor.commit();
    

    You retrieve Button save in onCreate() but do nothing with it. What do you want it to do? How about connecting its onClickListener by adding

      save.setOnClickListener(mySaveHandler);
    

    to onCreate()? Then:

    View.OnClickListener mySaveHandler = new View.OnClickListener() {
      public void onClick(View v) {
       // Save preferences here instead/aswell
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm kinda new to android development, but i'm trying to make a xml parser.
I'm new to android development and I'm trying to make an android app that
I am new to android development and have a confusion that if an activity(
I'm new to Android development, i'm trying to port an IOS app to Android.
I am new to android development and I've hit a hurdle when trying to
I'm new to android apps development and I have a basic sqlite question. What
I am new to Android development and i have been asked to create an
I'm very new to Android development and just started to study. What I'm trying
I am new to android development and I have a question about the insert
I am new to android development but in the past few weeks I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.