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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:38:55+00:00 2026-05-31T05:38:55+00:00

I know the question can be regarded as politically incorrect, but I’m designing an

  • 0

I know the question can be regarded as “politically incorrect”, but I’m designing an app which “by design” must get the attention of people within the maximum possible distance range, otherwise it will not be used… 🙂

I’m currently using SoundManager class, and this is the code which plays my ogg clip:

public void playSound(int index) { 
     int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 
     mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 0, 0, 1.0f); 
}

The problem is that the sound volume I get the clip played with appears to be dependent by “Settings/Audio/Voulme” settings the user has set. Instead it appears to be indipendent by the hardware volume buttons setting.

Is there a way for an Android app to play a sound to the maximum physical volume allowed by the device?

  • 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-31T05:38:57+00:00Added an answer on May 31, 2026 at 5:38 am

    I’d suggest using getStreamMaxVolume and setStreamVolume to do this:

    int origionalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
    

    Then once you’re done just set it back to the original volume.

    I think I was beaten to the punch, ahh well 🙂

    Some code that actually does this, I’m using the MediaPlayer rather than the soundpool as this gives you a play complete callback which doesn’t appear to be present on the soundpool:

    final AudioManager mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    final int originalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
    MediaPlayer mp = new MediaPlayer();
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mp.setDataSource("content://media/internal/audio/media/97");
    mp.prepare();
    mp.start();
    mp.setOnCompletionListener(new OnCompletionListener()
    {
       @Override
       public void onCompletion(MediaPlayer mp)
       {
          mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, originalVolume, 0);
       }
    });
    

    Btw the with call mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 0, 0, 1.0f); the streamVolume values are actually floats 0 -> 1 that represent a percentage of the maximum value so you’d really just want to put in 1.0f there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question can be answered by searching in google. But I have
I know this question might be little silly but I can't seem to find
I know this question is similar to several previous ones, but I can't find
Yes, I know this question has been asked before, but I can't find an
I know this is an easy question but I can't figure it out or
I know this can seem a weird question but for me it would be
I don't know whether this question can be answered here, but I hope it
Simple question - can I put an app in Apple's AppStore which is only
From the question you can probably tell that I don't know much about code!
Question: How can I document Ruby code using Doxygen? Disclaimer: I know ruby already

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.