speaker

How to detect alarm ringing or other apps using speaker? [closed]

左心房为你撑大大i 提交于 2019-11-27 02:58:20
问题 I am developing a music app. I want to detect that other apps using speaker or alarm ringing for play/pause music. For phone call i use PhoneStateListener. I tryed OnAudioFocusChangeListener for to detect other audios. But didn't work. I wondering how to solve this problem. 回答1: I solved my problem for default alarm application: public static final String ALARM_ALERT_ACTION = "com.android.deskclock.ALARM_ALERT"; public static final String ALARM_SNOOZE_ACTION = "com.android.deskclock.ALARM

Android : Force audio routing

[亡魂溺海] 提交于 2019-11-26 22:00:29
问题 I would like to change the sound device output in my Android app. I want to use the speaker of the phone when the headset plugged. I've tried to use setSpeakerphoneOn from AudioManager class audioManager.setSpeakerphoneOn(true); with audioManager.setMode(AudioManager.MODE_IN_CALL); but I don't want to set the MODE_IN_CALL ! I want to stay in MODE_NORMAL. I've search around the AudioSystem class and I've found an application, "SoundAbout", which do that. You can choose the speaker for media

how to turn speaker on/off programmatically in android 4.0

不问归期 提交于 2019-11-26 17:34:10
I play a file through media player and I want to give options like speaker on/off, play though headset, bluetooth ,etc. I tried the below code which works well for android 2.2 but I want something that can also work for 2.2 and 4.0 both. Can you help me to programmatically turn the speaker on/off and playing via headphones? AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); if(isOn){ audioManager.setMode(AudioManager.MODE_IN_CALL); audioManager.setMode(AudioManager.MODE_NORMAL); }else{ //Seems that this back and forth somehow resets the audio channel

how to turn speaker on/off programmatically in android 4.0

元气小坏坏 提交于 2019-11-26 05:28:42
问题 I play a file through media player and I want to give options like speaker on/off, play though headset, bluetooth ,etc. I tried the below code which works well for android 2.2 but I want something that can also work for 2.2 and 4.0 both. Can you help me to programmatically turn the speaker on/off and playing via headphones? AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); if(isOn){ audioManager.setMode(AudioManager.MODE_IN_CALL); audioManager.setMode