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

  • SEARCH
  • Home
  • 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 8671253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:54:16+00:00 2026-06-12T18:54:16+00:00

I have a player app with a seekbar for volume control inside. I use

  • 0

I have a player app with a seekbar for volume control inside. I use this code:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) 
    { 
        int index = volumeSeekbar.getProgress(); 
        volumeSeekbar.setProgress(index + 1); 
        return true; 
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        int index = volumeSeekbar.getProgress(); 
        volumeSeekbar.setProgress(index - 1); 
        return true; 
    }
    return super.onKeyDown(keyCode, event); 
}

The code works well. Now when I press hardware volume control down/up button my seekbar moves. But now I have an issue with the volume dialog in Android. When i press the hardware button it doesn’t show anymore. I mean the dialog in the picture:

enter image description here

What can I do to fix it and show the volume dialog as usual?

Edit:

Here is my code for using AudioManager:

 private void initControls() {
     try {
         volumeSeekbar = (SeekBar)findViewById(R.id.seekBar1);
         audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
         volumeSeekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
         volumeSeekbar.setProgress(audioManager
                               .getStreamVolume(AudioManager.STREAM_MUSIC));   

         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_MUSIC, progress, 0);
             }
         });
     }
     ...
}
  • 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-12T18:54:18+00:00Added an answer on June 12, 2026 at 6:54 pm

    The dialog is not shown because you are consuming the key event in the onKeyDown() function. Therefore the event is not propagated further and the volume dialog is not shown.

    There is a simple solution for this. In the documentation for the onKeyDown() function it says that you have to return false to prevent the event from being consumed. Now the dialog will show again.

    Nevertheless, I don’t think you are using the right approach to receive the information about volume. When the volume dialog shows up, the user can drag the seekbar in it and change the volume, such change is not reflected in calls to onKeyDown() function. You could utilize AudioManager and its getStreamVolume() function:

    AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app, I have a video player. There is a custom control panel
I'm trying to build an app, which should have Flash Player control, which plays
i built a very basic video player app in Xcode 4.3.2 i have 3
I have a C# app, and I'm looking at using the Windows Media Player
I have a Rails app implementing a game, so it's expected that a player
I am making an app in which I have to open default audio player.
So I have a Player view with seekbar and play/pause/rewind, etc. buttons, which are
This is my problem: I have a player class and SwipeDetector Class in c#,
I am implementing an audio player in my app. and I have a UITableView
I have Expression Dark theme for the entire WPF application. <Application x:Uid=Application_1 x:Class=MyShow.Player.App xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

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.