android-audiomanager

What permissions are needed to programmatically mute a phone call, from a background app?

瘦欲@ 提交于 2019-12-02 00:55:20
I have an Android app that happens to be running in the background on the user's Android phone, while the user is speaking on a phone call that someone placed to the user. At a certain point, my app would like to silence the audio from the phone call and play its own audio. Moreover, I'd like to do this without disrupting the user's speech. What permission does my app need to have, to do this? Is there any permission that's available to third-party apps that is sufficient to let my app do this? It looks like AudioManager.setStreamMute(STREAM_VOICE_CALL, true) will mute the audio output from

How to check and redirect audio between wired headset and speaker phone?

跟風遠走 提交于 2019-12-01 23:26:28
问题 I am developing a simple app , that should toggle between speaker phone and wired headset to play audio on a button click event. I am trying to make use of isWiredHeadsetOn() function, but it says that this is deprecated for Android API lvl 5 onwards. So how do I check if currently audio is playing or not through wired headset so that I can redirect it to the phone speaker? Note: I start my app with the headphone plugged to the 3.5mm jack of the phone. This is my attempt at the code so far:

Retrieving the application name that has audio focus change

狂风中的少年 提交于 2019-12-01 18:18:56
I can't seem to find anything related to finding out what application got audio focus. I can correctly determine from my application what type of focus change it was, but not from any other application. Is there any way to determine what application received focus? "What am I wanting to do?" I have managed to record internal sound whether it be music or voice. If I am currently recording audio no matter the source, I want to determine what application took the focus over to determine what my application need's to do next. Currently I am using the AudioManager.OnAudioFocusChangeListener for my

Retrieving the application name that has audio focus change

南楼画角 提交于 2019-12-01 17:20:24
问题 I can't seem to find anything related to finding out what application got audio focus. I can correctly determine from my application what type of focus change it was, but not from any other application. Is there any way to determine what application received focus? "What am I wanting to do?" I have managed to record internal sound whether it be music or voice. If I am currently recording audio no matter the source, I want to determine what application took the focus over to determine what my

How to mute sound and vibration for all notifications in Android 5.0+?

前提是你 提交于 2019-12-01 12:26:30
问题 I would like to disable sound and vibration for all incoming notifications. I don't mind if phone call vibration gets switched off, too. But the users volume settings for phone calls shouldn't be touched. Thanks to the AudioManager, muting the sound of notifications is easy: audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true); Disabling the vibration of notifications, however, is harder than expected. The AudioManager has this deprecated method for vibration settings:

How to mute sound and vibration for all notifications in Android 5.0+?

好久不见. 提交于 2019-12-01 11:55:08
I would like to disable sound and vibration for all incoming notifications. I don't mind if phone call vibration gets switched off, too. But the users volume settings for phone calls shouldn't be touched. Thanks to the AudioManager , muting the sound of notifications is easy: audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true); Disabling the vibration of notifications, however, is harder than expected. The AudioManager has this deprecated method for vibration settings: audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF) This,

Changing ringer volume during ringing

安稳与你 提交于 2019-12-01 08:12:09
I'd like to change the ringer volume during ringing. Code below sets it during ringing (it is changed in system settings) but it doesn't come to effect with actual ringing (only the next ring call will use new value). Can I force this changes to make them effect Immediately? AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audio.setStreamVolume(AudioManager.STREAM_RING, volume, AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND); After some research and tests I've found that volume change is possible only in very early stage of incomming

AudioManager.isWiredHeadsetOn() is not working in android

两盒软妹~` 提交于 2019-12-01 05:36:48
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 this happening? It looks like this is a bug. You will always get false when calling isWiredHeadsetOn unless your add MODIFY_AUDIO_SETTINGS permission to AndroidManifest.xml : <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 来源: https://stackoverflow.com/questions/6249884/audiomanager-iswiredheadseton-is-not-working-in-android

Changing ringer volume during ringing

安稳与你 提交于 2019-12-01 04:44:14
问题 I'd like to change the ringer volume during ringing. Code below sets it during ringing (it is changed in system settings) but it doesn't come to effect with actual ringing (only the next ring call will use new value). Can I force this changes to make them effect Immediately? AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audio.setStreamVolume(AudioManager.STREAM_RING, volume, AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND); 回答1: After

What is audio focus in Android class AudioManager?

社会主义新天地 提交于 2019-12-01 03:30:15
The AudioManager class has a method abandonAudioFocus() and another method requestAudioFocus() . I wonder what is audio focus? And what happens if an AudioManager object gets the audio focus or lost the audio focus? Thank you! karnok It has to do with priority when using the speakers, to prevent playing many things at once or being overridden. If you requestAudioFocus() , you're declaring that you want control. You can then listen with onAudioFocusChange(int focusChange) to see if anything else tries to play a sound. You may forcefully lose focus (like during a phone call) but then you can