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 6320393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:57:51+00:00 2026-05-24T15:57:51+00:00

I am trying to update a TextView which will show the system volume. I

  • 0

I am trying to update a TextView which will show the system volume. I have managed to capture the current system volume and display it, but it doesn’t update when the volume is turned up/down (obviously).

I know there is an easy solution somewhere I just cant think! onKeyListeners?

I am now using this but it doesnt work:

TextView sysVol = (TextView)findViewById(R.id.systemVolume);        
    sysVol.setOnKeyListener(new OnKeyListener()
    {                           
        public boolean onKey(View v, int keyCode, KeyEvent event) {
              if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {

                //system volume
                int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
                int i = curVolume * 4;  
                String aString = Integer.toString(i);   

                TextView sysVol = (TextView)findViewById(R.id.systemVolume);
                sysVol.setText(aString);

                return true;
            }
                return false;
        }
    });
  • 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-05-24T15:57:52+00:00Added an answer on May 24, 2026 at 3:57 pm

    Well, the pseudo approach would be the following scenario:

    1) Attach a listener to the view
    2) Filter the different events in the callback
    3) Update the TextView upon the (event==volume_up OR event==volume_down)
    

    Basically, you’d want to implement the View.onKey()-method for this to be a minor bump in the road, instead of the current roadblock-state.

    Summary: Add the following snippet to your code (some modification needed)

    public YourClassHere extends SomethingCool implements OnKeyListener /*<-- important part*/
    {
        public boolean onKey(View v) {
          // do something when the selected button is pushed
          return true;
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I have been trying to update a TextView field, when i Tap on the
I'm trying to set the text of a TextView which sounds simple enough but
Hello I am trying to update the textview at every certain time, but it
I trying to update a model on a callback but the validation is causing
I am trying to update a column in my table which was last inserted.
I am trying to update the ListView with timer . I have implemented the
I am trying to populate a TextView based on the current selected options in
I'm trying to make a widget to my app, but it doesnt update. I
Do I have to do anything special to display UTF-8 characters in a TextView?

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.