Questions tagged [android-audiomanager]

AudioManager provides access to volume and ringer mode control.

AudioManager provides access to volume and ringer mode control.

AudioManager Class Reference

792 questions
20
votes
3 answers

KeyEvent.ACTION_UP fired TWICE for ACTION_MEDIA_BUTTON

I have this broadcast receiver for ACTION_MEDIA_BUTTON which actually works for both Android 2.x and Android 4.1, but for some strange reason, on Android 2.x (only), I get each even twice (for a single click on the pause button, of course): public…
an00b
  • 11,338
  • 13
  • 64
  • 101
19
votes
2 answers

What is AudioFlinger and why does it fail TONE_PROP_ACK?

In my application I issue the following statement: toneGenerator.startTone(ToneGenerator.TONE_PROP_ACK, 600); Which works very well on a cheap LG LS670 running Android 2.3.3 but doesn't sound at all on all other phones I have, ranging from Android…
Eternal Learner
  • 2,602
  • 5
  • 27
  • 38
18
votes
2 answers

Calling setVolumeControlStream from a Service

I need to call setVolumeControlStream from a service that plays some sound via STREAM_SYSTEM. Obviously in an Activity that is no problem, but how can I do this with a service?
Force
  • 6,312
  • 7
  • 54
  • 85
18
votes
4 answers

Enable Silent Mode in android without triggering Do Not Disturb

Having a little trouble bending my head around this one. In my volume control app I am trying to set the system sound profile to SILENT ONLY without triggering do not disturb, my app has access to modify DND settings and notification access, no…
18
votes
6 answers

Alternative to the deprecated AudioManager.isWiredHeadsetOn?

The method AudioManager.isWiredHeadsetOn() is deprecated from api level 14, how do we now detect if a wired headset is connected?
Bjarke Freund-Hansen
  • 28,728
  • 25
  • 92
  • 135
17
votes
0 answers

How to reliably fetch and detect changes to the active audio route on Android?

I have a feature where I need to fetch current AND detect switch of the active audio output device of the system. Something like: run app -> fetch current device (which might be embedded speakers) connect bluetooth speaker -> detect switch to…
17
votes
1 answer

Android - How to get list of AudioManager / AudioSystem parameters

AudioManager has a setParameters method that accepts a Key-Value pair in string representation ("parameter_name=parameter_value"). Internally, it calls native AudioSystem.setParameters. The only way to get a parameter value is if you know its name,…
Oren
  • 937
  • 1
  • 10
  • 34
17
votes
1 answer

Alternative for AudioManager.setRingerMode() in Android 5.0 (API 21)

I used AudioManager.setRingerMode() to handle the device volume in my application using: AudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT) to turn off vibration and sound. AudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE) to…
Eldoth
  • 275
  • 2
  • 8
15
votes
5 answers

Android MediaPlayer - how to play in the STREAM_ALARM?

I've tried settings the audio stream of the media player in my application using the following code but when I do this I hear no sound in the emulator. If I don't set the stream for the player then the audio plays fine. I'm sure I'm using this wrong…
James
  • 1,237
  • 4
  • 22
  • 43
15
votes
1 answer

What is the default audio stream of TTS?

As far as I can tell, there are currently are 7 audio streams in Android: STREAM_ALARM (for alarms) STREAM_DTMF (for DTMF Tones) STREAM_MUSIC (for music playback) STREAM_NOTIFICATION (for notifications) STREAM_RING …
an00b
  • 11,338
  • 13
  • 64
  • 101
15
votes
2 answers

Check if headset is connected on different API levels

I have an application that targets API Level 19+. I need to check if headset is connected (either of wired or bluetooth). I see that AudioManager.isWiredHeadsetOn() is deprecated starting from API Level 16 and the documentation offers to use…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
14
votes
3 answers

Ringer mode change listener Broadcast receiver?

AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: Log.i("MyApp","Silent mode"); break; case AudioManager.RINGER_MODE_VIBRATE: …
akd
  • 6,538
  • 16
  • 70
  • 112
14
votes
3 answers

Android: Get Notified when the current Mode inside AudioManager gets changed

In Android I need to get notified when the current audio mode gets changed. I can get this value through getMode() but this is polling. I don't want to poll every few seconds. What are my options? (Please note that I'm not asking about…
Hagai L
  • 1,593
  • 1
  • 18
  • 40
14
votes
1 answer

Looking for an example of the new Android API setMediaButtonReceiver

Currently I am using mAudioManager.registerMediaButtonEventReceiver(mRemoteControlResponder); but this is now deprecated in 5.0 and replaced by setMediaButtonReceiver. There are 5 links in Google all pointing to developer.android.com. Has…
John Smith
  • 3,493
  • 3
  • 25
  • 52
14
votes
7 answers

Android : Calling Activity from Fragment

I am using fragments inside an activity. I am using MediaRecorder to for audio recording. I have two part of an activity. 1st itself the Activity which will list the recorded file. On it's right side the AudioRecording Activity is called when one…
1
2
3
52 53