Forcing volume control to be for the Media volume in my app

by John Lussmyer » Tue, 28 Dec 2010 01:44:18 GMT


Sponsored Links
 My app plays very short sounds frequently.
I'd like the user to be able to use their normal volume controls to turn the
volume up or down.
The problem is that while my app is running, the volume control defaults to
the Ringer volume, and only adjusts the Media volume if the user happens to
press the button while one of my beeps or clicks is playing.
How can I tell Android that while my app is active, the volume controls
should default to adjusting the Media volume?

-- 



Re: Forcing volume control to be for the Media volume in my app

by Mark Murphy » Tue, 28 Dec 2010 01:49:34 GMT


 


In the affected activity, call setVolumeControlStream().

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 


Sponsored Links


Re: Forcing volume control to be for the Media volume in my app

by John Lussmyer » Tue, 28 Dec 2010 02:11:25 GMT


 Thanks.  Using:
        setVolumeControlStream(AudioManager.STREAM_MUSIC);
did the trick.
(Sure would be nice if the setVolumeControlStream() docs actually told you
what the valid values are, or at least where to find them.)





-- 



Other Threads

1. Getting a complete list of android native drawables

> I've checked that one out, that's for Android 1.0 which is old.

Not that old. Are there any you've found that do not work?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~---------~--~----~------------~-------~--~----~

2. Capture data packet of dev phone

Hi,

     Does anybody knows how can i capture data packets transmitted/
received by Dev Phone (real hardware)? this is very important in
development stage. In emulator it's very easy, just start wireshark. I
need to do the same in real hardware. Anybody knows?

Thanks a lot

Breno
--~--~---------~--~----~------------~-------~--~----~

3. Why can not edit /init.rc on adp1 with firmware 1.1?

4. Checking how a program was installed?

5. A simple question regarding inter-process communication.

6. Android + SugarCRM + Web Services = SugaDroid (Open Source)

7. How can I Resize Tabs (TabWidget ?)