Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to force audio through the speakers when headphones are plugged in?

Tags:

android

I've tried the recommended

setSpeakerphoneOn(true)  

and the unrecommended

AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_SPEAKER); 

but neither has worked.

I've tried

setWiredHeadsetOn(false) 

but that doesn't work either, and is deprecated.

Interestingly,

isSpeakerphoneOn() 

reports true, as does

isWiredHeadsetOn() 

Additionally, the following permission is set

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 
like image 436
secureboot Avatar asked Jul 26 '11 18:07

secureboot


People also ask

How can I play audio through my speaker when my headset is plugged in?

Use an audio splitter or Bluetooth adapter A splitter offers a plug-and-play solution. Simply plug the splitter into your PC and plug the headphones into one port and the speakers into another. It's best to buy a high-quality audio splitter. Cheap splitters can negatively affect the quality and volume of your sound.

How do I turn on speakers when headphones are plugged in Windows 10?

Look for the sound icon on the bottom-right corner of your PC's screen. Right-click on it and select 'Sounds'. Click on the 'Playback' tab and select your headphones from the list of devices. Right-click on it and tap on 'Set as default device'.

How do you switch from headphones to speakers without unplugging?

Make yourself a little box, with a stereo input jack socket (or TRRS socket if required) and wire two stereo output jack sockets in parallel with this. Plug in a suitable cable between the box and your audio source, and plug headphones and/or speakers into the output sockets.


1 Answers

The answer turned out to be the following, with tips from Android - Getting audio to play through earpiece

audioManager.setMode(AudioManager.MODE_IN_CALL); audioManager.setSpeakerphoneOn(true); 

Ignore setRouting, it does nothing in APK > 10. Ignore comments about setMode. Ignore comments about setWiredHeadsetOn. Make sure you have MODIFY_AUDIO permissions.

like image 108
secureboot Avatar answered Sep 17 '22 11:09

secureboot