Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Route audio via speaker when headphone plugged it

How we can route audio output via speaker even when the headset is plugged in?

My code:

    if(audioManager.isWiredHeadsetOn())
    {
        audioManager.setWiredHeadsetOn(false);
        audioManager.setSpeakerphoneOn(true); 
        audioManager.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);  
        audioManager.setMode(AudioManager.MODE_NORMAL); 

    }

Am I missing something here?

like image 501
MegaMind Avatar asked Nov 25 '10 06:11

MegaMind


1 Answers

Did you try adding <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> to your AndroidManifest.xml ?

http://developer.android.com/reference/android/Manifest.permission.html#MODIFY_AUDIO_SETTINGS

like image 170
Sebastian Roth Avatar answered Nov 03 '22 07:11

Sebastian Roth