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
7
votes
1 answer

How to Detect Headset Capabilities

I know how to detect whether a headset is plugged in but some headsets (e.g Samsung EHS60ANNBE) come with the PAUSE/PLAY (a.k.a KeyEvent.KEYCODE_HEADSETHOOK) button only, without the PREV/NEXT... I would like to be able to detect whether the headset…
an00b
  • 11,338
  • 13
  • 64
  • 101
7
votes
2 answers

AudioManager sending message to a Handler on a dead thread?

I am trying to programmatically raise the volume to the STREAM_MUSIC stream's maximum value, but I am having a "Sending message to a Handler on a dead thread" issue when I do. Also, it seems like it does not raise the volume 100% of the time,…
Dwebtron
  • 777
  • 13
  • 27
7
votes
2 answers

Volume change Listener: Is registerMediaButtonEventReceiver preferable to onKeyDown?

Looking for a "most comprehensive & compatible (i.e. all Android versions...)" way to listen to volume changes, I found 2 different approaches to handle this: registerMediaButtonEventReceiver onKeyDown + SettingsContentObserver Which method is…
7
votes
2 answers

Android - is it possible to find out which app has audiofocus?

There's an app on my phone that keeps taking audio focus, even when no sound is playing. I'm wondering as an app developer if I'd be able to inform the user which app it is, or if I can tell if my app has audio focus?
StackOverflowed
  • 5,854
  • 9
  • 55
  • 119
6
votes
2 answers

How to set volume for text-to-speech "speak" method?

I'm at a lost. I want to be able to adjust the speak volume. Whatever I do, I can't increase its volume. How do I make it as loud as that found in the Android settings (as below)? System Settings -> Voice input and output -> Text-to-Speech settings…
mmmmm5
  • 151
  • 1
  • 1
  • 14
6
votes
2 answers

setSpeakerphoneOn from AudioManager is not changing speakerphone value on android 12, it always remains false. Why?

fun toggleSpeaker(context: Context) { isSpeakerPhoneSelected.value?.let { val audioManager: AudioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager audioManager.setSpeakerphoneOn = !it …
CaitlynCodr
  • 238
  • 1
  • 15
6
votes
2 answers

How to play audio through earpiece in android 12?

I am developing a voice call app for android using PeerJS and WebView. And I want the audio to play through the earpiece. Here is my code, private fun initAudio(){ am = getSystemService(AUDIO_SERVICE) as AudioManager volumeControlStream =…
Sujith S Manjavana
  • 1,417
  • 6
  • 33
  • 60
6
votes
1 answer

AudioManager.isWiredHeadsetOn() is not working in android

I want to check whether heaset is plugged in or not... I did it like this AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE); Log.i("am.isWiredHeadsetOn()", am.isWiredHeadsetOn()+""); But i am always getting false value... Why is…
coderslay
  • 13,960
  • 31
  • 73
  • 121
6
votes
0 answers

Android: How to play Gapless audio loop in MediaPlayer?

I know this question asked multiple times in this platform but none of them are solving my issue. I was trying to play a sound file in a loop but when a loop is complete first time there is a noticeable gap. I have sound files in .M4A format. I was…
6
votes
1 answer

How to stop other apps sounds?

I have an app that needs to play a sound, and it needs to set the volume at 100% ALWAYS (it's an alarm sound). I use this piece of code: // First I set the volume to 100% AudioManager mAudioManager = (AudioManager)…
nachoplaza
  • 173
  • 1
  • 10
6
votes
0 answers

How to get all audio devices for Android APIs < 23

how can i get all device info not using the method of api 23 ? AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_ALL); //or GET_DEVICES_OUTPUTS is there any way? In this case the target api is 19 - KitKat. Thank you.
6
votes
1 answer

How to play user dial pad tone on my custom keypad press in android?

In my app, I have a custom key pad and want to play tick tone on key press. The below code is giving me the sound. AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); float vol = 1f;…
Bhargav Kumar R
  • 2,190
  • 3
  • 22
  • 38
6
votes
0 answers

Play sound to a headset and record from the speakerphone microphone

In android, you can play and record sound in the speaker mode: setSpeakerphoneOn(boolean on). In this case, the system will use the loudspeaker and a special 'loud' record configuration for the mic (I am not sure how it is called properly). The…
user1256821
  • 1,158
  • 3
  • 15
  • 35
6
votes
1 answer

Android AudioManager.setMode(MODE_NORMAL) fails

I have 2 VoIP apps I'm developing that need to work together; one is a softphone app (App A) that uses various audio modes as expected i.e. RINGTONE, IN_COMMUNICATION, etc. The other app (App B) needs audio mode NORMAL. I try to make sure they…
alpartis
  • 1,086
  • 14
  • 29
6
votes
1 answer

Unable to retrieve AudioTrack pointer for write()

I am trying to implement AudioTrack to retrieve audio in my android device for incoming call from IAX but facing exception after some while . private void writeBuff(short[] buf) { try { if (this.track == null) { …